rahul1671986 / struts2-jquery

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

Dialog <sj:dialog modal generate duplicate forms for each dialog box generated #742

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
(This is for feature requests and bugs in Struts2 jQuery Plugin - for
getting help, please use the User Group.
http://groups.google.com/group/struts2-jquery )

What steps will reproduce the problem?
1.  Generate a dialog box with <sj:dialog and put a form inside it then submit 
it
2.  If u click on link to generate same dialog again the form still in the Dom 
tree, but it will generate 2, 3, 4, 5 same form with same name for each time u 
click on open the dialog link or button.
3.  It cause my app to resumitting the same form everytime because the newly 
generated form in at the end of the form stack.

The Fix:
    I put 

    $('#userFeedBackForm').remove(); 
    //to kill the form from DOM Tree so that each new dialog will      generate a new form

   after each submit inside dialog button js function 
   (buttons= "{   'Submit': function() {  ...etc)

What is the expected output? What do you see instead?

Which struts2 version?
3.2.1
Which struts2-jquery plugin version?
3.2.1

Please provide any additional information below.
The dialog box works fine with any other popup dialog that dont have a form 
inside.

Original issue reported on code.google.com by mychicag...@gmail.com on 5 Jan 2012 at 7:56

GoogleCodeExporter commented 9 years ago
Is this Issue relevant with existing 3.3.1 version? Maybe you should also ask 
in the jQuery UI Forum.

Original comment by johgep on 15 May 2012 at 2:28

GoogleCodeExporter commented 9 years ago
I am using version nr. 3.3.3 and I still have this issue:
<sj:dialog id="dialog" autoOpen="false" modal="true" width="600" height="500" 
position="center">
  <s:form id="myForm" action="myAction" namespace="/myNameSpace" theme="simple" method="POST">
   <fieldset>
        <sj:submit
            id="submitButton"
            button="true"
            validate="true"
            validateFunction="customValidation"
            onBeforeTopics="startBlockUI"
            dataType="json"
            requestType="POST"
            targets="target"
        />
        <span id="target"></span>
        <input id="closeButton" type="button" value="<s:text name='text.close'></s:text>" onclick="javascript:$('#dialog').dialog('close')"/>
   </fieldset>
  </s:form>
</sj:dialog>

I am using sj:submit outside dialogs as well - no issues.
Can you please take a look? I tried debugging for some time and could not find 
the issue. It is just clear that the event for submit is triggered twice.

Original comment by bitl...@gmail.com on 23 Aug 2012 at 12:53

GoogleCodeExporter commented 9 years ago
Can you please verify if this problem still exists in latest SNAPSHOT 
3.4.0-SNAPSHOT?

Following Example works without duplicated submit.

    <div id="formResult"></div>
    <sj:dialog id="mydialog" title="Dialog with local content">
    <s:form id="form" action="echo" theme="simple" cssClass="yform">
        <fieldset>
            <legend>AJAX Form</legend>
            <div class="type-text">
                <label for="echo">Echo: </label>
                <s:textfield id="echo" name="echo" value="Hello World!!!"/>
            </div>
            <div>
                <sj:submit 
                    id="formSubmit1"
                    targets="formResult" 
                    value="AJAX Submit" 
                    indicator="indicator"
                    button="true"
                    />
            </div>
        </fieldset>
    </s:form>
    </sj:dialog>

Original comment by johgep on 10 Sep 2012 at 2:36

GoogleCodeExporter commented 9 years ago
I get your point. But the fact is that this form will not run a separate 
request just for form validation.

Even without testing this I can tell it isn't going to save the day.

Myself, I am making a separate request for loading the dialog content (simple 
$.ajax) after the dialog itself has been initialized.

Original comment by bitl...@gmail.com on 11 Sep 2012 at 1:59