一个js插件编写的有关问题,涉及到jquery的事件绑定

一个js插件编写的问题,涉及到jquery的事件绑定


(function($, window, document,undefined) {
    //定义Bar的构造函数
    var Bar = function(ele, opt) {
        this.$element = ele,
        this.defaults = {
            'percent': 100,//进度条总百分比是100
            'curPercent': 0,//当前进度条为0
            'steps':10//步长为10
        },
        this.options = $.extend({}, this.defaults, opt);
    };
    //定义Bar的方法
    Bar.prototype = {
        init: function() {
         this.$element.on('update',this.update);
        },
        update : function(event,steps) {
         var _steps=steps||this.options.steps;
         var progress=this.$element.children();
         var text=this.options.curPercent+_steps+"%";
         progress.width(text).Text(text+" 正在加载数据");
        }
    };
    
    //在插件中使用Bar对象
    $.fn.progress = function(options) {
        //创建Bar的实体
        var bar = new Bar(this, options);
        //调用其方法
        return bar.init();
    };
})(jQuery, window, document);



一个js插件编写的有关问题,涉及到jquery的事件绑定

问题如图,我用chrome调试这个代码,发现进入这两个方法的this是不同的,问题来了,我想要在update这个function里调用到这个插件里定义的Bar对象里的东西,怎么做?

------解决思路----------------------
         this.$element.on('update',$.proxy(this.update, this));

------解决思路----------------------
Bar.prototype = {
       _o:this,
        init: function() {

         this.$element.on('update',this.update);

        },

        update : function(event,steps) {

         var _steps=steps
------解决思路----------------------
_o.options.steps;

         var progress=this.$element.children();

         var text=this.options.curPercent+_steps+"%";

         progress.width(text).Text(text+" 正在加载数据");

        }

    };