Skip to content

Commit

Permalink
Changed the way that autocompleteURL is used to overwrite autocomplet…
Browse files Browse the repository at this point in the history
…eOptions.source
  • Loading branch information
garjitech committed Jun 6, 2011
1 parent dba37a1 commit 33dd86b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions js/jquery.tagedit-1.1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@
}

// set the autocompleteOptions source
if(options.autocompleteURL)
options.autocompleteOptions = $.extend({ source: options.autocompleteURL}, options.autocompleteOptions);
if(options.autocompleteURL) {
options.autocompleteOptions.source = options.autocompleteURL;
}

// Set the direction of the inputs
if(this.attr('dir').length > 0) {
Expand Down
20 changes: 12 additions & 8 deletions playground.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,22 @@
{ "id": "3", "label": "Greylag Goose", "value": "Greylag Goose" }
];
$('#local-source input.tag').tagedit({
autocompleteURL: localJSON
autocompleteOptions: {
source: localJSON
}
});

// Function Source
$('#function-source input.tag').tagedit({
autocompleteURL: function(request, response){
var data = [
{ "id": "1", "label": "Hazel Grouse", "value": "Hazel Grouse" },
{ "id": "2", "label": "Common Quail", "value": "Common Quail" },
{ "id": "3", "label": "Greylag Goose", "value": "Greylag Goose" }
];
return response($.ui.autocomplete.filter(data, request.term) );
autocompleteOptions: {
source: function(request, response){
var data = [
{ "id": "1", "label": "Hazel Grouse", "value": "Hazel Grouse" },
{ "id": "2", "label": "Common Quail", "value": "Common Quail" },
{ "id": "3", "label": "Greylag Goose", "value": "Greylag Goose" }
];
return response($.ui.autocomplete.filter(data, request.term) );
}
}
});
});
Expand Down

0 comments on commit 33dd86b

Please sign in to comment.