java - Dynamic input is not recognized in struts2-jquery tags -


in application need change content of textfield dynamically code given below:

<script type="text/javascript">     $.subscribe('before', function(event, data) {                         $('#text').val('text changed jquery');     });                </script>         <s:form id="form2" action="textchange" >             <s:textfield id="text" name="text" value="hello world!!!"/>                                                             <sj:submit  targets="result" onbeforetopics="before" /> </s:form>                 

my expecting output

text changed jquery 

but i'm getting

hello world!!! 

i'm using struts2-jquery-plugin 3.5.1. how dynamic output.

note: not best way that.

but remove subscribe , onbeforetopics attribute. add id submit button , bind click event it.

<script type="text/javascript">   $(function(){     $("#form2submit").click(function() {          $('#text').val('text changed jquery');     });   }); </script>  <s:form id="form2" action="textchange">           <s:textfield id="text" name="text" value="hello world!!!" />                                                           <sj:submit id="form2submit" targets="result" /> </s:form> 

any other way. using <sj:a> tag subscribe.

<script type="text/javascript">   $(function(){     $.subscribe('before', function(event, data) {               $('#text').val('text changed jquery');     });    }); </script>  <s:form id="form2" action="textchange">           <s:textfield id="text" name="text" value="hello world!!!" />                                                           <sj:a targets="result" onclicktopics="before" formids="form2" button="true">     submit   </sj:a> </s:form> 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -