ShihMingSyu / struts2-jquery

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

Form submit and topics fired twice for submit button in dialog #573

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1) s:form element.
2) a sj:dialog outside the s:form
3) a submit button using sj:a or sj:submit within content of dialog which 
submit the form in 1) when clicked (using the formIds param and points to the 
s:form) 

What is the expected output? What do you see instead?
The ajax form should be fired once only. 
However, I checked the chrome developer tools's network status and two xhr 
request were fired after clicking the button.
If adding params like onBeforeTopics and assign an alert function with it, the 
alert would also prompt twice.

Which struts2 version?
2.2.3

Which struts2-jquery plugin version?
3.0.2

Original issue reported on code.google.com by quincyle...@gmail.com on 27 Jun 2011 at 5:38

GoogleCodeExporter commented 9 years ago

Original comment by johgep on 27 Jun 2011 at 1:46

GoogleCodeExporter commented 9 years ago
Can you please try if following commit for version 3.2.0 solve this problem?

http://code.google.com/p/struts2-jquery/source/detail?r=1542

You can get the latest SNAPSHOT from Maven Repository.

http://oss.sonatype.org/content/repositories/snapshots/com/jgeppert/struts2/jque
ry/

Original comment by johgep on 24 Oct 2011 at 5:26

GoogleCodeExporter commented 9 years ago
With the version version 3.2.0 I'm getting the same problem, any solution?

Original comment by teto...@gmail.com on 24 Nov 2011 at 5:32

GoogleCodeExporter commented 9 years ago
I am also facing the same problem. I am using Struts2.2.3 and Plugin version 
3.2.0. 

Original comment by nitin.co...@gmail.com on 8 Jan 2012 at 7:38

GoogleCodeExporter commented 9 years ago
I figured out a workaround use a <sj:div> instead of putting a <s:form> 
directly. Something like this :

<sj:dialog autoOpen="false" modal="false" onCloseTopics="reloadcountry"
                   id="countryDialog" loadingText="Loading..." title="My Dialog"
                   >
            <sj:div href="addcountryaction.action"></sj:div>
        </sj:dialog>

But there's a limitation to this, the onSuccessTopics of <sj:submit> doesn't 
work exactly as expected.

<script type="text/javascript">
            $.subscribe('closeDialog',function(event,data){
                alert('m done');
                alert(document.getElementById('countryDialog'));
                $("#countryDialog").dialog('close');
            });
        </script>

The above code executes on successful form submission but it shows only two 
alert boxes and unable to close the dialog. In javascript console the error 
that shows up is :
Uncaught TypeError: Object [object Object] has no method 'dialog'

Original comment by nitin.co...@gmail.com on 8 Jan 2012 at 7:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I figured out a completely working workaround. Simply removing the <sj:head> 
from the form page which I called through <sj:div> did the job.

I have posted the complete example at 
http://www.onlinexamples.com/showfullexample.action?idexamples=83&title=Adding%2
0To%20A%20Select%20Through%20Ajax%20Without%20Refreshing%20The%20Page

Original comment by nitin.co...@gmail.com on 8 Jan 2012 at 8:06