Title: Combobox onClick/loader Post by: jega on December 26, 2016, 05:56:35 AM Have a strange problem
Having a combobox <input id="unitSearch" name="unitSearch" class="easyui-combobox" style="width:300px" data-options=" loader: unitsLoader, mode: 'remote', valueField: 'id', textField: 'name', formatter: formatItem, hasDownArrow: false, iconCls:'icon-search', prompt: 'Indtast søgeord'"> A loader var unitsLoader = function(param,success,error){ var searchWord = param.q || ''; if (searchWord.length <= 1){return false} $.ajax({ url: 'getfromdb.asp', dataType: 'jsonp', data: { sw: searchWord, st: 'unitsearch', }, success: function(data){ var items = $.map(data, function(item,index){ return { id: item.unitID, name: item.unitName, fv: item.unitFV }; }); success(items); }, error: function(){ error.apply(this, arguments); } }); } And a formater function formatItem(row){ var s = '<span style="font-weight:bold">' + row.name + '</span><br/>' + '<span style="color:#888">' + row.fv + '</span>'; return s; } Then i have this script code $( document ).ready(function(){ $('#unitSearch').combobox('textbox').keyup(function(e){ //console.log(e.keyCode); if (e.keyCode == 13){ findNode($('#unitSearch').combobox('getValue')); } }); }); Everything working perfect. Show items in combobox depending on searchword. Press enter on an item, it show the node in the tree. Now i add the following code, because i want to findNode when onClick $('#unitSearch').combobox({ onClick: function(r){ //console.log(r) findNode(r.ID); } }); Nothing Works now. The loader is not called. So no result to the combobox Anyone that can explain why ?? regards Jesper Title: Re: Combobox onClick/loader Post by: jarry on December 26, 2016, 07:07:49 AM When click on a item of the combobox, the 'onClick' event fires. Please look at your code
Code: $('#unitSearch').combobox({ Title: Re: Combobox onClick/loader Post by: jega on December 26, 2016, 07:35:39 AM Hi jarry.
Yes the r.ID had to be r.id, BUT thats not the main problem When i add the script $('#unitSearch').combobox({ onClick: function(r){ //console.log(r) findNode(r.id); } }); The loader is never called, and then it never calls getfromdb.asp. |