How to call a method inside a javascript object

后端 未结 5 1460
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-08 17:23

I\'m just learning about how to best organize my javascript code, and I had a question regarding this small piece of code I wrote:

var reportsControllerIndex = {         


        
5条回答
  •  甜味超标
    2021-02-08 18:00

    You want to store the this binding in a variable.

    drawMap: function() {
        var _this = this;
        $.getJSON('/reports.json', function(data) {
            _this.plotMapPoints(data);         
        });
    }
    

提交回复
热议问题