Skip to content

Commit cddf2a4

Browse files
committed
Autocomplete: code improvements for multiple demo
1 parent 5c55462 commit cddf2a4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

demos/autocomplete/multiple.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
return val.split(/,\s*/);
1717
}
1818
function extractLast(term) {
19-
return split(term)[split(term).length - 1];
19+
return split(term).pop();
2020
}
2121

2222
$("#birds").autocomplete({
@@ -27,7 +27,7 @@
2727
},
2828
search: function() {
2929
// custom minLength
30-
var term = extractLast($(this).val());
30+
var term = extractLast(this.value);
3131
if (term.length < 2) {
3232
return false;
3333
}
@@ -37,14 +37,14 @@
3737
return false;
3838
},
3939
select: function(event, ui) {
40-
var terms = split( $(this).val() );
40+
var terms = split( this.value );
4141
// remove the current input
4242
terms.pop();
4343
// add the selected item
4444
terms.push( ui.item.value );
4545
// add placeholder to get the comma-and-space at the end
4646
terms.push("");
47-
$(this).val( terms.join(", ") );
47+
this.value = terms.join(", ");
4848
return false;
4949
}
5050
});

0 commit comments

Comments
 (0)