如何使用棘轮启用push.js ajax内容加载器

Sea*_*lus 10 javascript ios ratchet-bootstrap push.js

我试图从棘轮实现push.js引擎:

http://maker.github.com/ratchet/#push

我从这里下载了棘轮文件:

http://maker.github.com/ratchet/ratchet.zip

并使用apache来服务所有js,css和html.所有文件都在同一目录中.

这是我的one.html文件:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Ratchet template page</title>

    <!-- Sets initial viewport load and disables zooming  -->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">

    <!-- Include the compiled Ratchet CSS -->
    <link rel="stylesheet" href="ratchet.css">

    <!-- Include the compiled Ratchet JS -->
    <script src="ratchet.js"></script>

  </head>
  <body>

  <!-- Make sure all your bars are the first things in your <body> -->
  <header class="bar-title">
    <h1 class="title">one.html</h1>
  </header>

  <!-- Wrap all non-bar HTML in the .content div (this is actually what scrolls) -->
  <div class="content">

    <ul class="list">
      <li>
        <a href="two.html">
          <strong>two</strong>
          <span class="chevron"></span>
        </a>
      </li>
    </ul>

  </div>

  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是我的two.html文件:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Ratchet template page</title>

    <!-- Sets initial viewport load and disables zooming  -->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">

    <!-- Include the compiled Ratchet CSS -->
    <link rel="stylesheet" href="ratchet.css">

    <!-- Include the compiled Ratchet JS -->
    <script src="ratchet.js"></script>

  </head>
  <body>

  <!-- Make sure all your bars are the first things in your <body> -->
  <header class="bar-title">
    <h1 class="title">two.html</h1>
  </header>

  <!-- Wrap all non-bar HTML in the .content div (this is actually what scrolls) -->
  <div class="content">

    <ul class="list">
      <li>
        <a href="one.html">
          <strong>one</strong>
        </a>
      </li>
    </ul>

  </div>

  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我如何将这两个文件链接在一起?

看起来像push.js,但是当我点击一个href时什么也没做.

我觉得我错过了一些关于这个实现的明显的东西.

谢谢您的帮助.

dou*_*oug 12

Ratchet可以处理触摸事件,这些事件在浏览器中不可用.在Chrome中,转到chrome:// flags /并启用"强制启用触摸事件".这应该成为浏览器开发的诀窍.如果你想在没有标志的桌面上工作,你将需要一个js框架来将触摸事件转换为指针事件.像https://github.com/maker/ratchet/blob/master/docs/js/fingerblast.js这样的东西应该可以解决问题.

  • 现在位于:https://github.com/twbs/ratchet/blob/master/docs/assets/js/fingerblast.js (2认同)

Zen*_*nce 10

Ratchet在移动设备上使用与桌面浏览器中使用的指针事件不同的触摸事件.

您可以使用前面答案中提到的Chrome标记,也可以使用@ fat的fingerblast.js将触摸事件转换为指针事件.

fingerblaster.js文件可以在这里找到:https: //github.com/stephanebachelier/fingerblast.js

重要提示:为了启用fingerblaster.js,您需要在body元素的末尾包含以下脚本(一旦加载了html内容):

<script type='text/javascript'>
    var fb = new FingerBlast ('body');
</script>
Run Code Online (Sandbox Code Playgroud)

这将创建一个新的FingerBlast对象并在html文档的主体上设置监听器(您可以将任何css选择器字符串放在'body'的位置).