Mithun Sreedharan
Mithun Sreedharan

Reputation: 51264

jQuery UI combobox Ajax options

I need to customize the combobox widget build from the jQuery UI Autocomplete http://jqueryui.com/demos/autocomplete/#combobox

Currently drop down options are predefined from the SELECT tag OPTIONS or from a JSON array.

//getter
var source = $( ".selector" ).autocomplete( "option", "source" );
//setter
$( ".selector" ).autocomplete( "option", "source", ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"] );

I want to populate the combobox options from a Ajax URL, how can i customize the widget?

Upvotes: 0

Views: 8345

Answers (1)

Ben Everard
Ben Everard

Reputation: 13804

There is a demo on how to do this via AJAX, you should just make sure your array is JSON encoded before it is returned to the autocomplete component.

If you're using PHP, take a look at the json_encode function.

Does this answer your question?

Upvotes: 3

Related Questions