2013-07-05 515 views
1

我在jQuery-ui網頁上發佈一個簡單的例子來實現一些標籤,但我有問題,所有3 div的內容都顯示在每個3選項卡顯示(唯一正確顯示的是標籤的名稱)。從我的網頁的完整JSP/HTML代碼是這樣的:jQuery的UI標籤:所有標籤顯示相同的內容

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

<html> 

    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
    <%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 
    <%@taglib prefix="sf" uri="http://www.springframework.org/tags/form"%> 

    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <link href="<c:url value="/css/main_style.css"/>" rel="stylesheet" type="text/css" /> 
     <link href="<c:url value="/css/jquery-ui-1.10.2.custom.css"/>" rel="stylesheet" type="text/css" /> 
     <script src="<c:url value="/scripts/jquery-1.9.1.js"/>" type="text/javascript"></script> 
     <script src="<c:url value="/scripts/jquery-ui-1.10.2.custom.js"/>" type="text/javascript"></script> 
     <title>Main window</title> 
     <base href="${pageContext.request.contextPath}/WR"> 

     <script> 
      $(function() { 
       $("#tabs").tabs(); 
      }); 
     </script> 
    </head> 

    <body> 
     <div id="header"> 
      <div id="a_image"><img src = "images/a.png"></div> 
      <div id="webapp_name"> dcdfsadfsadfsa </div> 
     </div> 
     <!-- <div id="mainframe"> --> 
     <div id="buttons"> 
      <ul> 
       <li><a href="MainView/report/instant"><img src = "images/instant_icon.png"></a></li> 
       <li><a href="MainView/report/datagap"><img src = "images/datagap_icon.png"></a></li> 
       <li><a href="MainView/report/integrity"><img src = "images/integrity_icon.png"></a></li> 
       <li><a href="MainView/report/logbook"><img src = "images/logbook_icon.png"></a></li> 
      </ul> 
     </div> 

     <div id="content"> 
      <div id="tabs"> 
       <ul> 
        <li><a href="#tabs2">Proind dolor iee</a></li> 
        <li><a href="#tabs3">Aenean lacinia</a></li> 
        <li><a href="#chartSummary">Summary</a></li> 
       </ul> 
       <div id="tabs2"> 
        <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p> 
       </div> 
       <div id="tabs3"> 
        <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p> 
        <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p> 
       </div> 
       <div id="chartSummary"> 
        <table> 
         <tr> 
          <c:forEach var="i" begin="1" end="${numGraficos}"> 
           <c:choose> 
            <c:when test="${i % 3 == 0}"> 
             <td><img src="chart/${i}"></td></tr> 
             </c:when> 
             <c:otherwise> 
            <td><img src="chart/${i}"></td> 
            </c:otherwise> 
           </c:choose> 
          </c:forEach> 
         </tr> 
        </table> 
       </div> 
      </div> 
     </div> 
     <div style="clear: both;"></div> 
    </div> 
</body> 
</html> 

有誰有一個關於這個問題的線索?

+3

只顯示相關的html呈現的代碼,並不是你使用服務器端的所有代碼 –

+0

plese使用jsfiddle.net的小提琴 –

+0

jsfiddle沒有jquery-ui – Hauri

回答

1

我終於自己解決了這個問題。這個link

這個問題有一個特定的教程我剛剛指定了每個選項卡必須遵循的URL。在我的情況下,正確的代碼是:

<ul> 
    <li><a href="MainView/report/datagap/result#tabs2">Proind dolor iee</a></li> 
    <li><a href="MainView/report/datagap/result#tabs3">Aenean lacinia</a></li> 
    <li><a href="MainView/report/datagap/result#chartSummary">Summary</a></li> 
</ul> 

希望這對任何人都有幫助!

0

這裏工作Fiddle。看起來你錯過了css文件。我添加了下面的CSS來小提琴。

http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css 
+0

謝謝。是的,我看到你的小提琴作品,但仍然不適合我。我已經修改了所有文件(圖像,CSS,JS等),html語法,刪除了代碼的一些部分,甚至將整個頁面減少到jQuery頁面中的「tabs」示例,但仍然不起作用... – Hauri

+0

​​最後標籤..哪裏是它的開放標籤..?或者它只是一個錯字錯誤? –

+0

是的,我知道我發佈的代碼中存在一些HTML錯誤。然而,我已經刪除了整個

標籤及其中的所有內容,並在所有三個標籤中一直顯示相同的內容... – Hauri