diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-03-24 15:22:34 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 95919924698e8b8e2458c86d98ec2b61834c022f (patch) | |
| tree | e59074ca142c3c3be2db63a4e84de8753c43cd7e /addons/web/static/src/js | |
| parent | 1c7fa2e72dd2b6d97d38a32d4246163ae8ef9200 (diff) | |
[REF] web: views: refactor $buttons handler unbinding
Diffstat (limited to 'addons/web/static/src/js')
4 files changed, 10 insertions, 34 deletions
diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js index 9344d3a9e21..d321c3f3e64 100644 --- a/addons/web/static/src/js/views/abstract_controller.js +++ b/addons/web/static/src/js/views/abstract_controller.js @@ -52,6 +52,9 @@ var AbstractController = Widget.extend({ this.renderer.appendTo(this.$el) ).then(this._update.bind(this, this.initialState)); }, + /** + * @override + */ destroy: function () { if (this.$buttons) { this.$buttons.off(); diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index f27a47ababc..0832530582c 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -33,15 +33,6 @@ var FormController = BasicController.extend({ this.toolbar = params.toolbar; this.mode = params.mode; }, - /** - * @override - */ - destroy: function () { - if (this.$buttons) { - this.$buttons.find('*').off(); - } - this._super(); - }, //-------------------------------------------------------------------------- // Public @@ -150,14 +141,10 @@ var FormController = BasicController.extend({ this.$buttons.append($footer.detach().contents()); } else { this.$buttons.append(qweb.render("FormView.buttons", {widget: this})); - this.$buttons.find('.o_form_button_edit') - .click(this._toEditMode.bind(this)); - this.$buttons.find('.o_form_button_save') - .click(this.saveRecord.bind(this)); - this.$buttons.find('.o_form_button_cancel') - .click(this._onDiscardChange.bind(this)); - this.$buttons.find('.o_form_button_create') - .click(this.createRecord.bind(this)); + this.$buttons.on('click', '.o_form_button_edit', this._toEditMode.bind(this)); + this.$buttons.on('click', '.o_form_button_save', this.saveRecord.bind(this)); + this.$buttons.on('click', '.o_form_button_cancel', this._onDiscardChange.bind(this)); + this.$buttons.on('click', '.o_form_button_create', this.createRecord.bind(this)); this._updateButtons(); } diff --git a/addons/web/static/src/js/views/kanban/kanban_controller.js b/addons/web/static/src/js/views/kanban/kanban_controller.js index 5d48fde2cca..8e79cd5fead 100644 --- a/addons/web/static/src/js/views/kanban/kanban_controller.js +++ b/addons/web/static/src/js/views/kanban/kanban_controller.js @@ -43,11 +43,6 @@ var KanbanController = BasicController.extend({ // true iff grouped by an m2o field and group_create action enabled this.create_column_enabled = false; }, - destroy: function () { - if (this.$buttons) { - this.$buttons.off(); - } - }, //-------------------------------------------------------------------------- // Public diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js index 713299c19ed..aec9d1bf70d 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -42,12 +42,6 @@ var ListController = BasicController.extend({ this.noLeaf = params.noLeaf; this.selectedRecords = []; // there is no selected record by default }, - destroy: function () { - if (this.$buttons) { - this.$buttons.find('*').off(); - } - this._super(); - }, //-------------------------------------------------------------------------- // Public @@ -104,12 +98,9 @@ var ListController = BasicController.extend({ renderButtons: function ($node) { if (!this.noLeaf && this.hasButtons) { this.$buttons = $(qweb.render('ListView.buttons', {widget: this})); - this.$buttons.find('.o_list_button_add') - .click(this._onCreateRecord.bind(this)); - this.$buttons.find('.o_list_button_save') - .click(this._onSave.bind(this)); - this.$buttons.find('.o_list_button_discard') - .click(this._onDiscard.bind(this)); + this.$buttons.on('click', '.o_list_button_add', this._onCreateRecord.bind(this)); + this.$buttons.on('click', '.o_list_button_save', this._onSave.bind(this)); + this.$buttons.on('click', '.o_list_button_discard', this._onDiscard.bind(this)); this.$buttons.appendTo($node); } }, |
