【问题标题】:pjax example not workingpjax 示例不工作
【发布时间】:2016-01-24 15:20:32
【问题描述】:

你能帮忙找出为什么 pjax 不工作吗?

https://plnkr.co/edit/CfB9rIKP7EknVNDiYZpR?p=preview

点击一个链接后,它只是转到页面(作为普通链接)

<!DOCTYPE html>
<html>

  <head>
    <link rel="stylesheet" href="style.css">
    <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
    <script src="https://raw.githubusercontent.com/defunkt/jquery-pjax/master/jquery.pjax.js"></script>

  </head>

  <body>
    <h1>Hello Plunker!</h1>
     <div class="container" id="pjax-container">
            Go to <a href="bla.html">next page</a>.
            </div>
  </body>
<script>
$(document).ready(function(){
  $(document).pjax('a', '#pjax-container')
});
</script>
</html>

【问题讨论】:

  • 开发者控制台有错误吗?
  • 可能是因为$(...).pjax is not a function错误

标签: jquery pjax plunker


【解决方案1】:

你必须像这样把你的 pjax-container 放在 bla.html 页面中:

<div class="container" id="pjax-container"> Go to <a href="bla.html">next page</a>. </div>

它现在可以工作了。

【讨论】:

  • 完全像 bla page
    测试
猜你喜欢
  • 2023-03-16
  • 2012-08-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多