Handle Enter key up event with GwtQuery

135 views Asked by At

I have this code that does not run:

    TextBox mobileTextBox = $("#mobile-search-input")
            .as(Widgets).textBox().widget();
    mobileTextBox.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent keyUpEvent) {
            if(keyUpEvent.getNativeKeyCode() == KeyCodes.KEY_ENTER){
                Multimap<String, String> state =  ArrayListMultimap.create();
                state.put("query", searchBox.getText());
                searchPage.go(state);
            }
        }
    });

My goal is to handle the ENTER keyup for a certain textbox div. Is there a better way to handle ENTER keyup instead of this with pure GwtQuery? If not, what is the correct way to cast a GwtQuery into a GWT TextBox widget?

1

There are 1 answers

0
Momo On BEST ANSWER

sure you can bind handler on a dom using GwtQuery. Thake a look at this https://code.google.com/p/gwtquery/wiki/GettingStarted#Binding_Events