2013-03-19 63 views
0

我想使用pjax的片段選項來只刷新頁面的一部分。沒有發生點擊,並沒有錯誤拋出,只有硬重新加載頁面。沒有阿賈克斯電話正在進行。在鉻pjax片段問題

<!DOCTYPE html> 
<html> 

    <head> 
    <title>PJAX TEST</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> 
    <link href="/css/reset.css" rel="stylesheet" media="all"> 
    <link href="/css/index-style.css" rel="stylesheet" media="all"> 

    <script src="http://code.jquery.com/jquery.js"></script> 
    <script src="/jquery.pjax.js"></script> 
    <script src="/script.js"></script> 
    </head> 

    <body> 

    <div class="wrapper"> 
     <div class="header"> 
      <ul id="navlist"> 
      <li><a href="/index.html">click</a></li> 
      <li><a href="/one/index.html">click 1</a></li> 
      <li><a href="/two/index.html">click 2</a></li> 
      <li><a href="/three/index.html">click 2</a></li> 
      </ul> 
     </div> 

     <div id="container"> 

      <div id="inner-content"> 

      <h1>YEA YEA - INDEX PAGE</h1> 
      <div id="text-block">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 

      </div> 
      </div> 

     </div> 

     <div class="footer"> 
      <h3>Sticky footer</h3> 
     </div> 
    </div> 

    </body> 
</html> 

測試和的script.js是

$(function(){ 


    $('li a').pjax("#container", { fragment: "#container" }); 

}); 

回答

1

不得不

<div id="container" data-pjax-container> 

到容器和

$(document).pjax('a', '[data-pjax-container]', { fragment: "#container" }); 

添加到JS