dgrid:从自定义 Widget 传播更改时出现问题
dgrid: Issue when propagating change from custom Widget
我无法在自定义小部件上传播 "change" 事件。这是我的小部件:
define([
"dojo/_base/declare",
"dijit/_Widget",
"dijit/_TemplatedMixin",
"dojo/on",
"dojo/text!./TopEditor.html",
], function (declare, _Widget, _TemplateMixin, on, domClass, template) {
return declare("myEditor", [_Widget, _TemplateMixin], {
templateString: template,
value: false,
_onClick: function (event) {
this.set("value", !this.get('value'));
this.emit("change");
},
_setValueAttr: function (value) {
this.value = value;
// ... do some dom stuff ...
}
});
});
问题是,在 Editor.js (https://github.com/SitePen/dgrid/blob/master/Editor.js#L477) 的第 477 行中,"this" 被赋予了 _updatePropertyFromEditor 方法,而 "this" 在我的上下文中是 domNode小部件而不是小部件本身,然后 "dgrid-datachange" 的传播不起作用 。难道我做错了什么?有错误吗?
在 https://github.com/SitePen/dgrid/blob/master/Editor.js#L477 seems to fix the Problem. The issue is posted already on github: https://github.com/SitePen/dgrid/issues/1310
中将 "this" 更改为 "cmp"
我无法在自定义小部件上传播 "change" 事件。这是我的小部件:
define([
"dojo/_base/declare",
"dijit/_Widget",
"dijit/_TemplatedMixin",
"dojo/on",
"dojo/text!./TopEditor.html",
], function (declare, _Widget, _TemplateMixin, on, domClass, template) {
return declare("myEditor", [_Widget, _TemplateMixin], {
templateString: template,
value: false,
_onClick: function (event) {
this.set("value", !this.get('value'));
this.emit("change");
},
_setValueAttr: function (value) {
this.value = value;
// ... do some dom stuff ...
}
});
});
问题是,在 Editor.js (https://github.com/SitePen/dgrid/blob/master/Editor.js#L477) 的第 477 行中,"this" 被赋予了 _updatePropertyFromEditor 方法,而 "this" 在我的上下文中是 domNode小部件而不是小部件本身,然后 "dgrid-datachange" 的传播不起作用 。难道我做错了什么?有错误吗?
在 https://github.com/SitePen/dgrid/blob/master/Editor.js#L477 seems to fix the Problem. The issue is posted already on github: https://github.com/SitePen/dgrid/issues/1310
中将 "this" 更改为 "cmp"