Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //function to auto complete in text box under "ADD" tab
- //This allows a user to input as many friends as he wishes
- function fillAutoComplete(friends_list) {
- $('input#opponents').autocomplete({
- source: $.map(friendList, function(item) {
- return {
- label: item.name,
- value: item.name,
- id: item.id
- }
- }),
- focus: function() {return false},
- multiple: true,
- select: function(event, ui) {
- var terms = (this.value).split(/,\s*/);
- terms.pop();
- terms.push(ui.item.value);
- terms.push("");
- this.value = terms.join(", ");
- var temp = $('input#oppID').val();
- if(temp != "") {
- $('input#oppID').val(temp + "," + ui.item.id);
- } else {
- $('input#oppID').val(ui.item.id);
- }
- return false;
- }
- });
- }
- //These two are needed for autocomplete. Allow for multiple values
- function split(val) { return val.split(/,\s*/);}
- function extractLast(term) { return split(term).pop();}
Add Comment
Please, Sign In to add comment