javascript - struts2 jquery 表仅显示在第一个选项卡上

标签 javascript jquery struts2 tabs struts2-jquery

我有一个包含 7 个选项卡的 div。每个表格都包含一个链接,单击该链接将显示一个包含表格的 div。这适用于第一个选项卡并很好地显示 div。但是,当您转到任何其他选项卡时,该 div 不会显示。我认为这是 javascript 的问题,我想知道您是否可以告诉我是否可以在 jquery 中选择唯一选项卡上的 div?

用于填充表的操作

<sj:tabbedpanel id="leadHomeAppTabs" cssClass="testing" useSelectedTabCookie="true">
    <s:iterator id="director" value="directorModel.directorList" status="directorStat">
        <s:set var="i" name="counter" value="#directorStat.count" />
        <s:url action="directorSummaryView.action" var="directorSummaryViewUrl">
            <s:param name="directorModel.directorListIndex" value="%{#directorStat.index}" />
        </s:url>

        <sj:div cssClass="test" label="%{#director.lineOfBusiness}" theme="simple" 
        labelposition="top" id="directorTab%{counter}" loadingText="Loading Line of Business Information..." 
        showLoadingText="true" href="%{directorSummaryViewUrl}" refreshOnShow="false3" preload="false" showErrorTransportText="false" />

        <sj:tab id="%{#director.lineOfBusiness}" target="directorTab%{counter}" label="%{#director.lineOfBusiness}"/>
    </s:iterator>
</sj:tabbedpanel>

调用 javascript 来显示 div 的链接

<sj:a href="#" onClick="javascript:showDivs('div2');">
    <s:property value="directorModel.directorScore.getCountAtLevel(2)"/>
</sj:a>

我想显示的表格(在每个选项卡上将被称为 div2,我认为这会导致问题,但选项卡的填充方式迫使它以这种方式运行)。

<sj:div id="div2" cssStyle="display:none">
    <table class="table table-striped platform-sum-table" >
        <thead>
            <th>Level</th>
            <th>Application Name</th>
            <th>ID</th>
            <th>Current Score</th>
            <th>Maximum Score</th>
        </thead>
        <tbody>
            <s:property escapeHtml="false" value="directorModel.directorScore.getAppListAtLevel(0)"></s:property>
        </tbody>
    </table>
</sj:div>

JavaScript

<script type="text/javascript">
    function showDivs(id) {
        $("#div2").toggle();}   
</script>

最佳答案

供将来引用:id 不是唯一的,因此我使用 OGNL 使其唯一

<s:set id="dirName" value="directorModel.directorScore.directorName"/>
<sj:div id="%{dirName}div2" cssStyle="display:none">
    <table class="table table-striped platform-sum-table" >
        <thead>
            <th>Level</th>
            <th>Application Name</th>
            <th>ID</th>
            <th>Current Score</th>
            <th>Maximum Score</th>
        </thead>
    <tbody>
        <s:property escapeHtml="false" value="directorModel.directorScore.getAppListAtLevel(0)"></s:property>
    </tbody>
</table>
</sj:div>

关于javascript - struts2 jquery 表仅显示在第一个选项卡上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17273903/

相关文章:

javascript - Bootstrap 单选按钮在 flask 中不起作用

javascript - 不明确的 JavaScript 错误 [nsSessionStore.js]

javascript - 验证我的 Angular 应用程序以便在 github 存储库上获得协作者

javascript - d3.js 支持每个节点的图像

javascript - 轻松集成 PhotoSwipe 的方法

jquery - ajax调用JQUERY中的变量数据

javascript - 动态绑定(bind)点击到 Google map 标记链接

java - 如何将复选框的多个值以param=value1%2Cvalue2格式发送到后端?

javascript - 修改表的索引行

css - 在 struts2 中覆盖 css_xhtml