Do I need to unbind jquery event before remove element?

前端 未结 3 794
北荒
北荒 2020-12-24 10:37

I have a page using jquery-ui-dialog. Each time the dialog opens, page contents load in using ajax. Then it binds some event using jquery \"on()\". When the dialog close,

3条回答
  •  猫巷女王i
    2020-12-24 11:32

    It's better to unbind but must.

    Most browsers handle this correctly and remove those handlers themselves.

    You can also see do-i-need-to-remove-event-listeners

    Better way to handle this problem, you can use the Event Delegate.

提交回复
热议问题