JQuery event model and preventing duplicate handlers

前端 未结 5 1720
眼角桃花
眼角桃花 2020-12-05 02:03

Once again I want to load a page which contains its own script into a div using $(\"divid\").load(...). The problem I face is related to events. Let\'s say we trigger(\"mo

5条回答
  •  甜味超标
    2020-12-05 02:45

    An excellent answer from

    bind event only once

    copyPastedInfo:

    if you can apply it, probably want to take a look at event.preventDefaultt and event.stopPropagation OR unbind and bind each time, within the method like

    function someMethod()
    {
      $(obj).off('click').on('click', function {});
    }
    

提交回复
热议问题