[REM] declarative elements binding, not sure there's much point and can add later

bzr revid: xmo@openerp.com-20120611144108-pw8pz5p06prsikxe
This commit is contained in:
Xavier Morel 2012-06-11 16:41:08 +02:00
parent b19354ae20
commit d6f3764645
1 changed files with 0 additions and 24 deletions

View File

@ -734,14 +734,12 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, {
setElement: function (element) {
if (this.$el) {
this.undelegateEvents();
this.unbindElements();
this.$el.replaceWith(element);
}
this.$element = this.$el = (element instanceof $) ? element : $(element);
this.el = this.$el[0];
this.bindElements();
this.delegateEvents();
return this;
@ -796,28 +794,6 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, {
undelegateEvents: function () {
this.$el.off('.delegated-events' + this._uid);
},
elements: {},
bindElements: function () {
var elements = getValue(this, 'elements');
if (_.isEmpty(elements)) { return; }
for (var selector in elements) {
if (!elements.hasOwnProperty(selector)) { continue; }
// TODO: ensure at least one element matched?
this[elements[selector]] = this.$(selector);
}
},
unbindElements: function () {
var elements = getValue(this, 'elements');
if (_.isEmpty(elements)) { return; }
for (var selector in elements) {
if (!elements.hasOwnProperty(selector)) { continue; }
delete this[elements[selector]];
}
},
/**
* Shortcut for ``this.$el.find(selector)``
*