2016-07-06 68 views
1

目前我在所有页面上都有问题。页面包含一个带有提交按钮和包含按钮的表格的问题。问题是每当我点击编辑按钮the tablecssjavascript都不见了。点击一个按钮后,CSS an javascript消失

这里是jascript代码

<script type="text/javascript"> 
    $(document).ready(function() { 
     var table = $('#datatable').dataTable(); 
     var tableTools = new $.fn.dataTable.TableTools(table, { 
      'aButtons' : [ ], 
      'sSwfPath' : 'js/copy_csv_xls_pdf.swf' 

     }); 

     $(tableTools.fnContainer()).insertBefore('#datatable_wrapper'); 
    }); 
</script> 

<table id="datatable" class="hover" > 
       <thead> 

      <tr> 
       <th width="80">Poll ID</th> 
       <th width="120">Poll Name</th> 
       <th width="120">Poll Description</th> 
       <th width="120">poll publisher</th> 


       <th width="60">Edit</th> 
       <th width="60">Delete</th> 
       <th width="60">Voter</th> 
           <th width="60">Afficher courbe</th> 

      </tr> 
      </thead> 
       <tfoot> 

      <tr> 
       <th width="80">Poll ID</th> 
       <th width="120">Poll Name</th> 
       <th width="120">Poll Description</th> 
       <th width="120">poll publisher</th> 


       <th width="60">Edit</th> 
       <th width="60">Delete</th> 
       <th width="60">Voter</th> 
           <th width="60">Afficher Courbe</th> 

      </tr> 
      </tfoot> 
      <c:forEach items="${listpolls}" var="poll"> 
        <tbody> 

       <tr> 
        <td>${poll.id_poll}</td> 
        <td>${poll.titre}</td> 
        <td>${poll.description}</td> 
        <td>${poll.emp_login}</td> 



        <td><a href="<c:url value='/poll/edit/${poll.id_poll}' />">Edit</a></td> 
        <td><a href="<c:url value='/poll/remove/${poll.id_poll}' />">Delete</a></td> 
        <td><a href="<c:url value='/poll/voter/${poll.id_poll}' />">Vote</a></td> 
        <td><a href="<c:url value='/sa/${poll.id_poll}' />">Afficher courbe</a></td> 

       </tr> 
      </c:forEach> 
          </tbody> 

     </table> 

下面是表的照片前,我点击编辑。

enter image description here

现在

enter image description here

正如你所看到的css和javascipt的代码都不见了。

我在这里做错了什么?任何帮助深表感谢。

+0

似乎你要进入页面'/ poll/edit/$ {poll.id_poll}',CSS和JS是否存在于该网页上? –

+0

其实** /民意调查/编辑/ $ {poll.id_poll} **被重定向到同一页面。 –

+0

比较页面重定向前后浏览器网络选项卡中的CSS和JS请求URL。 –

回答

0

问题是在链接的href中的/poll/edit/...等。即使重定向,浏览器仍然认为你在不同的目录中,从那里你的样式的相对路径&脚本将不起作用。

指定的基本目录为网页上的所有链接:
<base href="http://www.domain.com/somebasedir/" />

那么不管重定向,例如这个样式表:
<link rel="stylesheet" type="text/css" href="path/style.css" />

应该总是期望的是:
/somebasedir/path/style.css

+0

我添加了基本的东西,并用** ** -1.12.3.min.js“/>”> **它工作,感谢您的帮助。 –