diff --git a/public/js/legacy/widgets/form/form.js b/public/js/legacy/widgets/form/form.js index 8e5e70cfce..373a0416ac 100644 --- a/public/js/legacy/widgets/form/form.js +++ b/public/js/legacy/widgets/form/form.js @@ -129,7 +129,8 @@ _f.Frm.prototype.setup = function() { // client script must be called after "setup" - there are no fields_dict attached to the frm otherwise this.script_manager = new wn.ui.form.ScriptManager({ frm: this - }) + }); + this.script_manager.setup(); this.watch_model_updates(); this.footer = new wn.ui.form.Footer({ diff --git a/public/js/wn/form/script_manager.js b/public/js/wn/form/script_manager.js index 77849bb26a..4e3627e5e7 100644 --- a/public/js/wn/form/script_manager.js +++ b/public/js/wn/form/script_manager.js @@ -1,7 +1,9 @@ wn.ui.form.ScriptManager = Class.extend({ init: function(opts) { $.extend(this, opts); - this.setup(); + }, + make: function(ControllerClass) { + this.frm.cscript = $.extend(this.frm.cscript, new ControllerClass({frm: this.frm})); }, trigger: function(event_name, doctype, name) { doctype = doctype || this.frm.doctype;