gigaZhang / struts2-jquery

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

targets attribute not working on submit tag #1008

Closed GoogleCodeExporter closed 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 )

Relevant portion of JSPs:
"crud.jsp"
<!Doctype html, taglibs, etc here !-->
    <html>
    <head>
    <s:head theme="css_xhtml" />
    <sj:head jqueryui="true" />
    <script type="text/javascript">
        $.subscribe('testtopic', function(event, data) {
            alert('testtopic Published!');
        });
    </script>
    <title>Exam CRUD</title>
    </head>
    <s:url namespace="/exam" action="ReadAll" var="readExamsTag" />
    <body>
        <s:include value="/WEB-INF/content/navigation.jsp" />
        <h2>Exam CRUD</h2>
        <sj:div id="formcontainer"></sj:div>
        <sj:div id="tablecontainer" loadingText="Loading.."
            reloadTopics="reloadTable" href="%{readExamsTag}">
        </sj:div>
    </body>
    </html>
------------------------------------------------------------------------------
ReadAll loads the following "table.jsp" into the "tablecontainer" div:

<s:url namespace="/exam" action="CreateForm" var="createFormTag" />
<p>
    Listed below are the exams currently available to students.
    <sj:a href="%{createFormTag}" targets="formcontainer">Add an exam</sj:a>
    <!The above anchor works perfectly fine. It loads the form into the div as expeceted>
</p>
<table>
    <! Table contents over here >
</table>
------------------------------------------------------------------------------
The form being loaded into "formcontainer" onclick by %{createFormTag}:
"add.jsp"
<sj:head />

<s:form  theme="css_xhtml" namespace="/exam" action="Create">
    <!Form fields>
    <input type="button" value="Cancel" onclick="$('#formcontainer').empty();">
    <sj:submit targets="formcontainer" onCompleteTopics="reloadTable" value="Add" />
</s:form>

<sj:a href="#" onClickTopics="testtopic">Test</sj:a>
------------------------------------------------------------------------------

What steps will reproduce the problem?
1. Click on the link to Add an exam in table.jsp (createFormTag)
2. Fill out the form and submit it in add.jsp
3. Click on the test link at the end of add.jsp

What is the expected output? What do you see instead?
Expected Output: On clicking "Add an exam" in table.jsp, add.jsp should be 
loaded into "formcontainer". On submitting the form in add.jsp, the result 
should be put into "formcontainer". On clicking "Test" in add.jsp, an alert 
window should be seen.
What is seen: Clicking "Add an exam" correctly loads add.jsp. Submitting the 
form though causes the result to load in a new page. Clicking "Test" does 
nothing.

Which struts2 version?
2.3.15

Which struts2-jquery plugin version?
3.6.0

Please provide any additional information below.
The targets attribute seems to be working on anchors but broken on submits. 
Maybe something I'm doing wrong which might be breaking the javascript in the 
form, so I've attached the referenced jsps (add.jsp, table.jsp, crud.jsp):

Original issue reported on code.google.com by vinay.b...@gmail.com on 12 Jul 2013 at 8:21

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Adding an id to the form seems to solve the targets problem.. Not sure why. But 
neither onCompleteTopics="reloadTable" nor onClickTopics="testtopic" are 
working still.

Original comment by vinay.b...@gmail.com on 12 Jul 2013 at 8:40

GoogleCodeExporter commented 9 years ago
Adding id attributes to my datepicker fields in my form seemed to fix the 
publishing problems.. 

Original comment by vinay.b...@gmail.com on 12 Jul 2013 at 9:19

GoogleCodeExporter commented 9 years ago
Great to here that is it know working.

Original comment by johgep on 5 Aug 2013 at 7:41

GoogleCodeExporter commented 9 years ago
This is not working in IE8 again after upgrade Struts2 and 
Struts2-jquery-plugin.

Which struts2 version?
2.3.16

Which struts2-jquery plugin version?
3.7.0

It is not working in IE8, but works in FireFox26

Does anyone know workaround ?

Original comment by bilinlin...@gmail.com on 7 Feb 2014 at 7:39