Reputation: 1744
I'm using the latest jQuery ui auto complete (version as per the js file: jQuery UI Autocomplete 1.8.13). I've successfully deployed the static autocomplete which looks something like: (Version 1)
$( "#Vendors" ).autocomplete({
source: [{ "id": "3", "value": "Ven 03" }, { "id": "1", "value": "Ven 01" }, { "id": "2", "value": "Ven 02"}]
});
But when I do the same dynamically using a remote file in my C# MVC2 web web-app the problem starts. Here's the code: (Version 2)
$( "#Vendors" ).autocomplete({ source: "/common/lookup?id=vendor" })
Version 2 gets the data suggessfully and I've verified the JSON generates is same as mentioned in Version 1 example. But when I start typing in the textbox - the autosearch is NOT performed as it is done in the Version 1.
In short the filtering of items as the user types is not available in the url version. Does it mean I've to query my data each time and perform that filtering on server side? Isn't the data cached?
Pls help, I'm stuck on this since about a day!
Edit 1: I've settled with the fact that it won't cache the search and that it'll go to server to search each new term.
Edit 2: Something useful for MVC - MVC extension for jQuery ui auto-complete:
http://www.codevoyeur.com/Articles/10/ASP.NET-MVC-HtmlHelper-Extensions-for-jQuery-AutoComplete.aspx
Upvotes: 0
Views: 643
Reputation: 11829
use this:
$( "#Vendors" ).autocomplete({ source: "/common/lookup" })
search variable: term instead id,
ajax query looks like: http://localhost/common/lookup?term=search_string
Upvotes: 1