【发布时间】:2018-03-02 23:26:30
【问题描述】:
我正在编写一个自定义编辑器插件,我需要将 this 传递给 jquery .change 事件。我怎样才能使以下工作?
(function($R)
{
$R.add('plugin', 'customplugin', {
onmodal: {
image: {
open: function($modal, $form)
{
this._load($modal)
}
}
},
_load: function($modal)
{
var $body = $modal.getBody();
this.$box = $R.dom('<div>');
this._getData('hello world'); //This works
$('.item').change(function (this) { //'this' passed in here
var value = $(this).val();
this._getFoo(value); //This does not work
return false;
}).keyup(function () {
$(this).change();
});
},
_getFoo: function(param) {
console.log('_getFoo() called with param ' + param);
},
});
})(Redactor);
【问题讨论】:
标签: javascript jquery oop