KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a problem with the jQuery's Select2. When the page loads, if O click on the search result it will select and trigger the event onchange, but only the first time. If I search another time, it won't. Here's my code (it's an Ajax based search): jQuery('#search_code').select2({ 'width': '600px', 'tokenSeparators': [',', ' '], 'closeOnSelect': false, 'placeholder': 'scan or type a SKU or product or ESN', 'minimumInputLength': 1, 'ajax': { 'url': 'lookProduct', 'dataType': 'json', 'type': 'POST', 'data': function (term, page) { return { barcode: term, page_limit: 3, page: page }; }, 'results': function (data, page) { return { results: data }; } } }).on('change', function (e) { var str = $("#s2id_search_code .select2-choice span").text(); DOSelectAjaxProd(this.value, str); //this.value }).on('select', function (e) { console.log("select"); });
Tags (comma-separated)
Save Edits
Cancel