作者ireullin (raison detre)
看板Ajax
标题[问题] ROR中 javascript不会重载
时间Wed Oct 1 11:32:22 2014
请问一下
我使用js去控制application的 navigation bar
我在assets中的javascripts目录里头加入一个common.js
程式码如下
结果我看console.log
发现只有第一次开网页会被呼叫
後面点了连结页面重刷之後就不会再被呼叫了
另外如果我使用click事件
也只有第一次点会有效果
点了连结页面重刷之後click也失效了
请问我有哪里搞错了吗
$(document).ready(
function()
{
console.log(this);
$('.cls_nav_link').each(
function()
{
if( $(location).attr('href') == $(this).prop('href') )
{
$(this).parent().addClass('active')
}
else
{
$(this).parent().removeClass('active')
}
}
);
}
)
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 125.227.141.182
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/Ajax/M.1412134344.A.34D.html
1F:推 qazwsx9006: 我猜是turbolink关系? 10/01 21:45