EasyUI Forum

General Category => General Discussion => Topic started by: catpaw on February 14, 2017, 04:47:48 PM



Title: [SOLVED] searchbox onChange fill datalist
Post by: catpaw on February 14, 2017, 04:47:48 PM
Hello all

I have a searchbox and datalist

I want to when you type on searchbox the datalist fill with the matches records

I have this code:

Code:
<input class="easyui-searchbox" style="width:95%;" data-options="
  prompt:'Buscar',
  searcher:doSearch,
  onChange:function(newValue,oldValue){
       doSearch(newValue);
  }">
<div id="dt" class="easyui-datalist" style="height:450px;" data-options="
                            url: 'retrieve/get.php',
                            method: 'get',
                            lines: true,
                            groupField: 'group'
                       ">

<script type="text/javascript">
function doSearch(value){
$('#dt').datagrid('load',{
q: value
});
}
</script>

But when I type a word I expect the event trigger and no happens, I have to click the icon search to the function trigger

I want the event onChange be like onMouse**

when I type some in mode automatic  the results ben shown in the datalist


Title: Re: searchbox onChange fill datalist
Post by: jarry on February 15, 2017, 12:27:28 AM
No 'onChange' event exists in the 'searchbox' plugin. Please try this code to attach the 'keyup' event to the inputing box.
Code:
<input class="easyui-searchbox" style="width:95%;" data-options="
  prompt:'Buscar',
  searcher:doSearch,
  inputEvents: $.extend({}, $.fn.searchbox.defaults.inputEvents, {
  keyup: function(e){
  var t = $(e.data.target);
  var opts = t.searchbox('options');
  t.searchbox('setValue', $(this).val());
  opts.searcher.call(t[0],t.searchbox('getValue'),t.searchbox('getName'));
  }
  })">


Title: Re: searchbox onChange fill datalist
Post by: catpaw on February 15, 2017, 07:43:13 AM
hello jarry

the code you put works perfect, I'm very greatful