hideto 发表于 2013-1-29 13:08:05

每天一剂Rails良药之Use Ajax to Trim Fast, Static Pages

今天让我们看看怎样使用Rails和Ajax得到静态页面。
看下面这个页面:
<ul>    <li>      <div id="product-1" class="product-overview">            <span class="title">Learn to Program (Chris Pine)                <%= link_to_remote "detail",                  :update => 'product-1-detail',                  :method => 'get',                  :url => '/catalog/details/1.html' %>            </span>      </div>      <div id='product-1-detail'></div>    </li></ul>
这里link_to_remote生成一个detail链接,用户点击它时,就会取得1.html并替换id为product-1-detail的div的content。默认method为post,我们取静态内容所以改为get。
页: [1]
查看完整版本: 每天一剂Rails良药之Use Ajax to Trim Fast, Static Pages