jQuery AutoComplete Trigger Change Event

后端 未结 13 1100
陌清茗
陌清茗 2020-11-27 15:50

How do you trigger jQuery UI\'s AutoComplete change event handler programmatically?

Hookup

$(\"#CompanyList\").autocomplete({ 
    s         


        
13条回答
  •  半阙折子戏
    2020-11-27 16:48

    You have to manually bind the event, rather than supply it as a property of the initialization object, to make it available to trigger.

    $("#CompanyList").autocomplete({ 
        source: context.companies
    }).bind( 'autocompletechange', handleCompanyChanged );
    

    then

    $("#CompanyList").trigger("autocompletechange");
    

    It's a bit of a workaround, but I'm in favor of workarounds that improve the semantic uniformity of the library!

提交回复
热议问题