How to use remote source with jquery ui combobox?

前端 未结 3 1904
情话喂你
情话喂你 2020-12-19 16:58

There is combobox with autocomplete enabled. How to pass JSON data as source for this combobox?

Upd. I\'ve found partial answer here - it allows me

3条回答
  •  臣服心动
    2020-12-19 17:54

    I just used next construction: 1. In combobox.js I put code from example that appears on https://jqueryui.com/autocomplete/#combobox and had changed _create & _createAutocomplete functions as follows:

     _create: function() {
            this.wrapper = $( "" )
                .addClass( "custom-combobox" )
                .insertAfter( this.element );
    
            var autocompleteSetup = this.options.autocompleteSetup;
            this.element.hide();
            this._createAutocomplete( autocompleteSetup );
            this._createShowAllButton();
        }
    
        _createAutocomplete: function(setupObject) {
    ...
    this.input = $( "" )
                .appendTo( this.wrapper )
                .val( value )
                .attr( "title", "" )
                .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
                .autocomplete(setupObject)...
    
    1. From page code where I'm creating the combo I am calling the create code as follows:

      var options = { autocompleteSetup : { delay: 100, minLength: 2, source: "http://your/data/hook/url" } }; $( "#subzero" ).combobox(options);

提交回复
热议问题