【发布时间】:2014-06-26 01:28:46
【问题描述】:
下面是coffeescript的sn-p:
$('a.view-more-link').on "click", ->
newPageString = $(this).attr("href").replace(/page=(.*?)&/, (a,b) ->
String("page=" + (Number(b) + 1) + "&")
)
$(this).attr "href", newPageString
当我单击链接时,我正在使用这种方法来增加页码。我的期望是,当我单击链接时,我的内容会加载并附加到我的差异中,然后 href 中的页码会增加:
Started GET "/community?page=2&per=8" for 33.33.33.1 然后href页面从2增加到3。
但是,当我在 rails 控制台中查看请求时,正在发生的事情。我看到正在调用新增加的页码:
Started GET "/community?page=3&per=8" for 33.33.33.1
我的问题是:
- 为什么会这样?
- 排除其他替代方案后,如何仅更改此脚本来解决我的问题?
感谢大家的宝贵时间!!!
【问题讨论】:
标签: javascript jquery ruby-on-rails ruby-on-rails-4 coffeescript