gpt4 book ai didi

magento2 - Magento 2 : Display Loader While Ajax call on Column row action?

转载 作者:行者123 更新时间:2023-12-03 17:32:10 26 4
gpt4 key购买 nike

网格xml列:

<column name='actions' class='My\Test\Ui\Component\Listing\Columns\Feeds\AdvancedActions'> 
<argument name='data' xsi:type='array'>
<item name='config' xsi:type='array'>
<item name='component' xsi:type='string'>My_Test/js/grid/columns/actions</item>
<item name='dataType' xsi:type='string'>text</item>
<item name='label' xsi:type='string' translate='true'>Actions</item>
<item name='sortOrder' xsi:type='number'>90</item>
</item>
</argument>
</column>

Action .js
define(
[
'jquery',
'underscore',
'mageUtils',
'uiRegistry',
'Magento_Ui/js/grid/columns/actions',
'Magento_Ui/js/modal/confirm'
], function ($, _, utils, registry, Column, confirm) {
'use strict';
return Column.extend(
{

/**
* Applies specified action.
*
* @param {String} actionIndex - Actions' identifier.
* @param {Number} rowIndex - Index of a row.
* @returns {ActionsColumn} Chainable.
*/
applyAction: function (actionIndex, rowIndex) {
var action = this.getAction(rowIndex, actionIndex),
callback = this._getCallback(action);

if (action.confirm) {
this._confirm(action, callback);
} else if (action.popup) {
this._popup(action, callback);
} else {
callback();
}

return this;
},


_popup: function (action, callback) {
var popupData = action.popup;
var dataType = popupData.type;

//Start loader
var body = $('body').loader();
body.loader('show');

if (popupData.file !== undefined && popupData.file !== '') {
$.ajax(
{
url: popupData.file,
async: false,
dataType: "text",
type: 'GET',
showLoader: true, //use for display loader
success: function (data) {
popupData.message = data;
}
}
);
}
//Stop loader
body.loader('hide');
},
});

二手 showLoader: truevar body = $('body').loader(); body.loader('show');但是在ajax请求时无法启动加载器。

需要在 ajax 调用期间启动加载程序的替代方法。

最佳答案

我遇到了同样的问题。就我而言,我需要加载 'jquery/ui'依赖性。

define(
[
'jquery',
...
'jquery/ui'

关于magento2 - Magento 2 : Display Loader While Ajax call on Column row action?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51781145/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com