
用的国产pjax: https://github.com/welefen/pjax
但是每次点击一个<a href="">link</a>都要跳转页面,pjax里的event.preventDefault()始终不能阻止链接,而且我在
$.pjax({
selector: 'a',
container: '#main'
})
前面加上:
$('a').click(function(e){
e.preventDefault()
})
也失效了
去除$.pjax...代码则成功阻止链接,我快被逼疯了,
加上层层包裹:
$('a').click(function(e){
e.preventDefault()
})
$.pjax({
selector: 'a',
container: '#main'
})
$('a').click(function(e){
e.preventDefault()
})
$('a').click(function(e){
e.preventDefault()
})
$('a').click(function(e){
e.preventDefault()
})
$('a').click(function(e){
e.preventDefault()
})
$('a').click(function(e){
e.preventDefault()
})
$('a').click(function(e){
e.preventDefault()
})
还是跳转了链接,咋回事啊?
1 crs0910 2015 年 3 月 27 日 你用 pjax 为什么要跳转链接? pjax 不是为了无刷新加载内容吗? 一般选取的 a 标签都是本域名的跳转。 |
4 yangqi 2015 年 3 月 27 日 |
5 Arrowing 2015 年 3 月 27 日 没用过pjax 你在preventDefault后面加上return false呢 |
6 kisshere OP 感谢楼上,已经解决啦 |