Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
734 views
in Technique[技术] by (71.8m points)

jsp - Struts 2 Jquery tab navigation

When navigating from one tab to another, i.e, on clicking the submit button in a tab1 (which is jsp) the tab2 has to get loaded. My code is below.

  <sj:tabbedpanel id="remotetabs" onCompleteTopics="tabcomplete"
    onChangeTopics="tabchange">
    <sj:tab id="tab1" href="test1.jsp" label="Tab One" />
    <sj:tab id="tab2" href="test2.jsp" label="Tab Two" />           
   </sj:tabbedpanel><sj:submit></sj:submit>

The jsp I have used is

 <s:url var="remoteurl1" action="ajax1" />
 <s:url var="remoteurl2" action="ajax2" />
 <sj:tabbedpanel id="tabpanel">
<sj:tab id="tab1" href="Test1.jsp" label="Tab One" />
<sj:tab id="tab2" href="Test2.jsp" label="Tab Two" />
 </sj:tabbedpanel>
 <sj:a href="#" onClickTopics="movetonextdiv" button="true">Next</sj:a>

and my script is

  $.subscribe('movetonextdiv', function(event, data) {
                   var selected = $("#tabpanel").tabs('option', 'selected');
                   $("#tabpanel").tabs('option', 'selected', selected + 1);
            });

I still face an issue like in the developer tools I am getting the error as Object doesn't support this property or method for the below line of code.

  var selected = $("#tabpanel").tabs("option", "selected");
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here you go :

<sj:a href="#" onClickTopics="movetonextdiv" button="true">Next</sj:a>


<script>
    $.subscribe('movetonextdiv', function(event, data) {
                    var selected = $("#tabpanel").tabs("option", "selected");
                    $("#tabpanel").tabs("option", "selected", selected + 1);
                });
</script>

<sj:tabbedpanel id="tabpanel" >...</sj:tabbedpanel>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...