diff --git a/etemplate/js/et2_core_baseWidget.js b/etemplate/js/et2_core_baseWidget.js index e7d315f201..9d6ac29096 100644 --- a/etemplate/js/et2_core_baseWidget.js +++ b/etemplate/js/et2_core_baseWidget.js @@ -200,7 +200,7 @@ var et2_baseWidget = et2_DOMWidget.extend(et2_IAligned, { if (this.node) { $j(this.node).bind("click.et2_baseWidget", this, function(e) { - return e.data.click(this); + return e.data.click.call(e.data,e); }); } @@ -232,10 +232,10 @@ var et2_baseWidget = et2_DOMWidget.extend(et2_IAligned, { return this.getDOMNode(this); }, - click: function(_node) { + click: function(event) { if (this.onclick) { - return this.onclick.call(_node); + return this.onclick.call(this, event); } return true; diff --git a/etemplate/js/et2_core_common.js b/etemplate/js/et2_core_common.js index f71858b522..027c33af6d 100644 --- a/etemplate/js/et2_core_common.js +++ b/etemplate/js/et2_core_common.js @@ -254,7 +254,14 @@ function et2_checkType(_val, _type, _attr, _cname) { // Parse JS code properly _val = et2_js_pseudo_funcs(_val, _cname); + if(_val == "1") return function() {return true;}; + // Check for remaining row data + if(_val.indexOf("$") >= 0 || _val.indexOf("@") >= 0) + { + // Still needs parsing + return _val; + } return new Function(_val); } catch(e) diff --git a/etemplate/js/et2_widget_button.js b/etemplate/js/et2_widget_button.js index 9ff40aed57..a277a05d0b 100644 --- a/etemplate/js/et2_widget_button.js +++ b/etemplate/js/et2_widget_button.js @@ -82,8 +82,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { return this.btn ? this.btn[0] : null; }, - // TODO: What's going on here? It doesn't get called, but something happens if you double click. - click: function() { + onclick: function(e) { // Execute the JS code connected to the event handler if (this.options.onclick) { @@ -140,7 +139,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { */ getDetachedAttributes: function(_attrs) { - _attrs.push("value", "class", "image"); + _attrs.push("value", "class", "image", "onclick"); }, getDetachedNodes: function() @@ -150,7 +149,9 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { setDetachedAttributes: function(_nodes, _values) { - this.btn = _nodes[0]; + this.btn = jQuery(_nodes[0]); + + this.image = _nodes[1]; if (typeof _values["id"] != "undefined") @@ -165,6 +166,19 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { { this.set_class(_values["class"]); } + + if (typeof _values["onclick"] == "string") + { + _values["onclick"] = new Function(_values["onclick"]); + } + if (typeof _values["onclick"] == "function") + { + this.options.onclick = _values["onclick"]; + this.btn.bind("click.et2_baseWidget", this, function(e) { + return e.data.click.call(e.data,e); + }); + } + } });