How can I set the value of gwt-Textbox through jquery.val()?

429 views Asked by At

I am using redQueryBuilder. It uses gwt for rendering the textbox elements. I want to change the value of textbox on focus of the element. I am trying the following code.

$(".gwt-TextBox").val("something");

I can the see the value in ui, but when submitting the form the value of the field is empty. Why is it so? Am I missing something big here?

Here is the html code which gets generated by redQueryBuilder.

<div><input type="text" class="gwt-TextBox ui-autocomplete-input" autocomplete="off"></div>
1

There are 1 answers

0
Abhijith Nagaraja On

In the JSNI, call like this

$win.$(".gwt-TextBox").val("something");

Suggestion, do not use class name to access as it will change and set the same value to all the elements which has same class unless that is you use case. To change the value of one element, access it by its id.

<div><input type="text" class="gwt-TextBox ui-autocomplete-input" autocomplete="off" id="someId"></div> 

$win.$("#someId").val("something");