Accessing class member variables inside an event handler in Javascript

后端 未结 3 683
执笔经年
执笔经年 2020-12-24 07:10

I have a quick question regarding the proper way to access Javascript class member variables from inside of an event handler that class uses. For example:

fu         


        
3条回答
  •  醉酒成梦
    2020-12-24 08:00

    You can also use JQuery.proxy, to create a proxy function with its context. You can than bind the proxy to events.

    Here is an example:

    var init_handler  =  $.proxy(this.init, this);
    $('#page_id').bind('pageinit', init_handler);
    

提交回复
热议问题