jQuery - trigger not produce the expected result

后端 未结 1 1607
天涯浪人
天涯浪人 2020-12-12 06:25

In my app, while page load i initiate my init function for 3 things,

  1. trigger and sending a page no. (i would like to pass page default as 1)

相关标签:
1条回答
  • 2020-12-12 06:49

    It's because you lose the this context. jQuery passes the DOM element as the context, not whatever the original context was.

    You need to bind the context of the function to your existing this:

    $(document).on("newMessage", this.onPageChange.bind(this));
    
    0 讨论(0)
提交回复
热议问题