gpt4 book ai didi

jquery - 委托(delegate)事件触发两次

转载 作者:行者123 更新时间:2023-11-30 23:47:07 25 4
gpt4 key购买 nike

此委托(delegate)事件会触发两次(并非总是如此,有时)。

client.bindButtonClickFunction = function(){

$("#client-plugin").delegate(".client-button", "click", function()
{
var id = this.id.split('-')[2];
client.retrieveMessageByID(id);
});
};

我在插入所有“.client-button”后调用该函数。

关于如何阻止它有什么想法吗?我尝试了 event.stopPropagation(),也尝试了取消委托(delegate)和重新委托(delegate),但均无济于事。

这是在 Chrome 中,作为 Chrome 插件的一部分。

最佳答案

根据您注册委托(delegate)的方式,您可能需要执行以下操作:

$("#client-plugin").undelegate('event').delegate('event', ...)

此外,尝试从处理程序中添加return false

关于jquery - 委托(delegate)事件触发两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6880039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com