EasyUI Forum
April 19, 2024, 04:59:53 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [SOLVED] searchbox onChange fill datalist  (Read 7620 times)
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« 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
« Last Edit: February 15, 2017, 07:43:34 AM by catpaw » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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'));
  }
  })">
Logged
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« Reply #2 on: February 15, 2017, 07:43:13 AM »

hello jarry

the code you put works perfect, I'm very greatful
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!