gigaZhang / struts2-jquery

Automatically exported from code.google.com/p/struts2-jquery
0 stars 0 forks source link

Update element value on submit #1026

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1.
 $.subscribe('before', function(event,data) {
      $('#data').val("Real DATA");
} 
<s:form id="form" action="AjaxTest">
      <input type="textbox" id="data" name="data" value="test data">
     <sj:submit formId="form" value="Submit Form" onBeforeTopics="before" targets="resultdiv"/>
</s:form>          

<div id="resultdiv"></div>

2."Submit Form" 

What is the expected output? What do you see instead?
- Expecting "Real DATA" is passed to action, instead "test data" is passed 
though the value in Text box is updated to "Real DATA"

Which struts2 version?
2.3.14.3

Which struts2-jquery plugin version?
3.5.1

Please provide any additional information below.

Original issue reported on code.google.com by gnanapra...@veradistech.com on 16 Aug 2013 at 10:13

GoogleCodeExporter commented 9 years ago
This is because the form data is already serialized before the beforeTopic 
fires.
You can manipulate the serialized form by accessing it via
event.originalEvent.formData

However, it might be a good idea for this plugin to add a beforeSerializeTopics 
for any pre-serialization actions.

Original comment by quincyle...@gmail.com on 5 Sep 2013 at 6:25

GoogleCodeExporter commented 9 years ago
Thanks for answering. Please create a separate Issue for Feature Requests.
Ideally a Patch is attached. ;-)

Original comment by johgep on 24 Sep 2013 at 6:09