Click not detected after Ajax Callback

I'm currently testing on something fairly simple. In my project you can add a listitem via a form and delete it immediately in an updated list. In the beginning of the file I bind the delete click handler: $(".delete").bind("click", this.deleteListitem); I would think that all elements with class "delete" can be removed before or after an Ajax call. So when I add a new listitem with class "delete", I try to click it but it doesn't enter the function. Older items do. The delete function: PanelRoadtrip.prototype.deleteListitem = function(e) { console.log("click"); e.preventDefault(); this.listId = $(event.currentTarget).parent().parent().attr("id"); this.listItemValue = $(event.currentTarget).parent().text().split(" delete")[0]; $.ajax({ type: "delete", url: Util.api + "/roadtrip/delete/" + this.tripId + "/" + this.listId + "/" + this.listItemValue, dataType: "json" }); //item verwijderen $(event.currentTarget).parent().remove(); }; Does someone has a simple solution for this problem, searched on Stackoverflow, but found nothing that works. Thanks in advance

以上就是Click not detected after Ajax Callback的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏