EasyUI Forum
September 13, 2025, 06:56:26 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: how to bind a keyup function to searchbox?  (Read 13644 times)
r2ferna
Newbie
*
Posts: 21


View Profile
« on: December 13, 2013, 11:54:02 AM »

Hi.
I'm using a searchbox as a continuous filter box.
I mean: On every key typed in the searchbox the content's datagrid is filtered.
I need to resolve two issues:

1) How to bind a keyup function to searchbox?

This is the searchbox
Code:
    
<input id="inpSearch2" class="easyui-searchbox" style="width:250px"
        data-options="prompt:'Tecleé aquí lo que deseé filtrar.'"></input> 

I have tried this:
Code:
  $('#inpSearch2').searchbox('textbox').keyup(function () { lk2_filtroLocal(this,'dg'); });
and this:
Code:
  $('#inpSearch2').bind('keyup',function(){alert('hola')});   
with no luck.

2) How to get the searchbox button (magnifier glass) to disable it?

Please can you help me?
MTIA.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: December 13, 2013, 05:10:25 PM »

Please try this code again, it works fine.
Code:
$(function(){
$('#inpSearch2').searchbox('textbox').keyup(function(e){
console.log(e.keyCode);
});
});
Logged
r2ferna
Newbie
*
Posts: 21


View Profile
« Reply #2 on: December 16, 2013, 08:49:46 AM »

Ok,
I had that line of code to the end of the $(function() , so i moved it just after the $(function() definition line, and Yes, it Works now!!

Please, how can I get the searchbox magnifier ?

Thanks again!!
 
Logged
vladj
Newbie
*
Posts: 5


View Profile
« Reply #3 on: December 19, 2018, 10:49:53 AM »

.. or you can bind custom validator to the searchbox. It's like:

Code:
$.extend($.fn.validatebox.defaults.rules, {
    valdatorFunction: {
        validator: function(value, param) {
if (value == undefined)
return true;
                        // validate value here. If OK - return true, else - false
        },
        message: 'Invalid syntax'
    }
});

and also

Code:
	$('#search').searchbox({
    searcher: doSearch,
    prompt: 'Enter search string'
})
.searchbox('textbox').validatebox({          // set custom validator
   required: false,
   validType:'validatorFunction[0]'     // [0] is the parameter passed to validator function
});
}
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!