diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 9d61504eec..782bd5edd2 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -392,7 +392,20 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], { return {ids:[],inverted:false}; }, - onselect: function() { + /** + * Event handler for when the selection changes + * + * If the onselect attribute was set to a string with javascript code, it will + * be executed "legacy style". You can get the selected values with getSelection(). + * If the onselect attribute is in app.appname.function style, it will be called + * with the nextmatch and an array of selected row IDs. + * + * The array can be empty, if user cleared the selection. + * + * @param action ActionObject From action system. Ignored. + * @param senders ActionObjectImplemetation From action system. Ignored. + */ + onselect: function(action,senders) { // Execute the JS code connected to the event handler if (this.options.onselect) { @@ -403,12 +416,14 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], { if(parts.length == 3 && typeof window.app[parts[1]] == "object" && typeof window.app[parts[1]][parts[2]] == "function") { - window.app[parts[1]][parts[2]].call(this, this.getSelection()); + // Call as Action callback + //window.app[parts[1]][parts[2]].apply( window.app[parts[1]], arguments); + window.app[parts[1]][parts[2]].apply( window.app[parts[1]], [this,this.getSelection().ids]); } } // Exectute the legacy JS code - else if (!(et2_compileLegacyJS(this.options.onselect, this, _node))()) + else if (!(et2_compileLegacyJS(this.options.onselect, this, this.div))()) { return false; } diff --git a/etemplate/js/et2_extension_nextmatch_controller.js b/etemplate/js/et2_extension_nextmatch_controller.js index 3ba592bdb2..20a01ed6db 100644 --- a/etemplate/js/et2_extension_nextmatch_controller.js +++ b/etemplate/js/et2_extension_nextmatch_controller.js @@ -64,7 +64,7 @@ var et2_nextmatch_controller = et2_dataview_controller.extend( } // Add our selection callback to selection manager var self = this; - this._objectManager.setSelectedCallback = function() {self._selectCallback(this);}; + this._objectManager.setSelectedCallback = function() {self._selectCallback.apply(self,[this,arguments]);}; // Call the parent et2_dataview_controller constructor this._super(_parentController, _grid, this, this._rowCallback, @@ -264,9 +264,13 @@ var et2_nextmatch_controller = et2_dataview_controller.extend( /** * Execute the select callback when the row selection changes */ - _selectCallback: function(action) + _selectCallback: function(action,senders) { - this._widget.onselect.call(this._widget, action); + if(typeof senders == "undefined") + { + senders = []; + } + this._widget.onselect.call(this._widget, action,senders); }, /** -- Implementation of et2_IDataProvider -- **/