EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: sky-t on October 05, 2016, 05:34:52 AM



Title: Searchbox keyDown
Post by: sky-t on October 05, 2016, 05:34:52 AM
Hi guys,

is there a possibility to get keyDowns in searchboxes?
I want the user if he pressing Enter to Search and if he is pressing CTRL+Enter to start a javascript function.


Thank you very much


Title: Re: Searchbox keyDown
Post by: jarry on October 06, 2016, 04:55:26 AM
Call 'textbox' method to get the inputing box and you will be able to bind any events on it.
Code:
var tb = $('#sb').searchbox('textbox');
tb.bind('keydown', function(e){
  //...
});


Title: Re: Searchbox keyDown
Post by: sky-t on October 07, 2016, 11:14:38 PM
Hi jarry,

thank you for your reply. When i don't use the searchbox searcher-function it works, but then the function of the search icon also doesn't work whats normal.
Can i trigger the search icon directly?

Thanks again


Thorsten



Title: Re: Searchbox keyDown
Post by: jarry on October 08, 2016, 07:36:55 AM
You can call 'getIcon' method to get the searching icon and then trigger its 'click' event.
Code:
var icon = $('#sb').searchbox('getIcon',0);
icon.trigger('click');


Title: Re: Searchbox keyDown
Post by: sky-t on October 08, 2016, 08:04:31 AM
Hi jarry,

this works great!!

Thanks a lot!!!