jQuery click events not firing within AngularJS templates

后端 未结 1 503
离开以前
离开以前 2020-12-04 19:29

This may be a bit of strange case where nobody has ever experienced this before, but I\'m posting this on the off-chance that somebody knows something I don\'t.

I\'m

1条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 19:47

    Since your clickme probably isn't available on DOM ready - rather it is pushed into the DOM by Angular when it loads template.html - you need to use jQuery's event delegation instead of using .click:

    $(document).on("click", ".clickme", function() {
      console.log("click");
    });
    

    This will ensure jQuery binds onto the document, then monitors for any click events on elements with the clickme class.

    0 讨论(0)
提交回复
热议问题