livequery - 确认()
我不明白为什么即使我点击“否”,这个确认()调用也会被触发。你能告诉我我做错了什么吗?
$('.deleteButton').livequery('click',function(){
if(confirm('Are you sure?')){
return true;
}else
{
return false;
}
return false;
});
HTML 标记:
<a class="smallbutton deleteButton" href="users.php?todo=delete&id=32">delete</a>
我检查过,它确实返回 false,但页面仍然重定向到单击的 A href 值。通常情况下,如果我返回 false,则不应该,对吧?
I don't get why this confirm() call fires up even though i hit "no". Can you tell me what i'm doing wrong?
$('.deleteButton').livequery('click',function(){
if(confirm('Are you sure?')){
return true;
}else
{
return false;
}
return false;
});
The HTML Markup:
<a class="smallbutton deleteButton" href="users.php?todo=delete&id=32">delete</a>
I checked and it does return false, but the page still redirects to the clicked A href value. Normally, if i return false, it shouldn't, right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将 livequery() 更改为 live()。 jQuery 支持相同的功能。刚刚在 FF 中进行了测试,它可以与 live() 一起使用,但甚至从未给过我 livequery() 的提示
Change livequery() to live(). jQuery supports the same functionality. Just tested in FF and it worked with live() but never even gave me a prompt with livequery()
我道歉:事实证明我正在将另一种行为附加到主内容容器内的所有锚点。我为deleteButton 添加了一个排除子句,现在它工作正常。
这是我最终的工作代码:
删除按钮行为的工作原理很简单:
I apologize: it turns out i was attaching another behaviour to all anchors inside the main content container. I added an exclusion clause for deleteButton and it works fine now.
Here is my final, working, code:
And the delete button behaviour works with a simple:
试试这个:
Try this: