force a search box (multifield) to search on keyboard event

0
Greetings,  I am struggling to force a  specific behaviour. I have a search bar , basically a multifield widget from the toolbox. My page has some other content I want to show when no one is using this search feature. When someone types something on the search and then enter, I would like to then, show the list , already with the proper results. I almost have this behaviour but have a little bit of a bug. My first enter, only switches the content to the list but ignores what is written in the multifield, so it shows me the entire list.  If then, I proceed to change the content of the search in the multifield , then it does work as it should, it filters my list with the criteria on the search. But I wanted that to happen with the first enter . The images may help understading my situation. Before any action. . Written the search context but Enter has not been pressed yet Enter was pressed (the entire list shows instead of only the result, this is the error/bug) IT IS NOT FILTERING THE LIST After deleting the search criteria and writting it again(no need to press enter, the list is filtered automatically here. This is the desired result but should be as long as you press enter. on the first enter, as long as any criteria that exists on the list is there.     I have an invisible button (opacity : 0) that does only the toogling (microflow ), hiding the content on image 1 and showing the list when you press enter Also have a html snippet, this is the content of it (I tried many things to force the search behaviour and still failed) notes: omnisearchbox = multifield / search field  changeScreen-button = insivible button that hides content and shows the list once pressed enter 13 = enter key ------------------------------------------- $(".omnisearchbox").keypress(function (event) {     var keycode = (event.keyCode ? event.keyCode : event.which);     if (keycode == '13') {         $(".changeScreen-button").click();         $(".omnisearchbox").trigger("onkeyup");      $(".omnisearchbox").keyup();     } }); I don’t know what else to do here, seems impossible to force the search in the script , it’s possible according to js and jquery but it’s not having an effect here. What can be done? Thanks in advance  
asked
2 answers
1

this is indeed working now with even a less line of code in the snippet : 

$(".omnisearchbox").keypress(function (event) {
    var keycode = (event.keyCode ? event.keyCode : event.which);
    if (keycode == '13') {
        $(".changeScreen-button").click()’
     $(".omnisearchbox").keyup();    
}
});

 

 

Now has a post bug, where it doesn’t search a second time ….

answered
0

Mendix 8.7 introduces a text box that handles the Enter keypress event. You may find this useful.

answered