Reload javascript file after an AJAX request

前端 未结 10 734
粉色の甜心
粉色の甜心 2020-12-13 20:25

After the request, the new elements created are not recognized by the event handlers in my jQuery code.

Is there a way to reload the file to re-register these events

10条回答
  •  被撕碎了的回忆
    2020-12-13 21:18

    You can also attach the click handlers to the body so that they never get destroyed in the first place.

    $('body').on('click', 'a', function(event) {
      event.preventDefault();
      event.stopPropagation();
      // some stuff
    })
    

提交回复
热议问题