Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <a class="action-menu-item"
- data-bind="attr: {href: $action().href},
- text: $action().label,
- click: $col.getActionHandler($action())"
- data-repeat-index="0"
- href="http://.../index.php/admin/customer/index/edit/id/1/">Edit</a>
- $actions['alert'] = [
- 'label' => __('Alert'),
- 'callback' => 'function() {alert("Action!")}'
- ];
- "alert": {
- "label": "Alert",
- "callback": "function() {alert("Action!")}"
- }
- getActionHandler: function (action) {
- var index = action.index,
- rowIndex = action.rowIndex;
- if (this.isHandlerRequired(index, rowIndex)) {
- return this.applyAction.bind(this, index, rowIndex);
- }
- },
- applyAction: function (actionIndex, rowIndex) {
- debugger
- var action = this.getAction(rowIndex, actionIndex),
- callback = this._getCallback(action);
- action.confirm ?
- this._confirm(action, callback) :
- callback();
- return this;
- },
- _getCallback: function (action) {
- var args = [action.index, action.recordId, action],
- callback = action.callback;
- if (utils.isObject(callback)) {
- args.unshift(callback.target);
- callback = registry.async(callback.provider);
- } else if (_.isArray(callback)) {
- return this._getCallbacks(action);
- } else if (!_.isFunction(callback)) {
- callback = this.defaultCallback.bind(this);
- }
- return function () {
- callback.apply(callback, args);
- };
- },
Add Comment
Please, Sign In to add comment