微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

magento2 – Magento 2:显示加载器当Ajax调用Column行动作时?

网格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>

Actions.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:true和var body = $(‘body’).loader(); body.loader( ‘节目’);但是在ajax请求时无法启动加载程序.

在ajax调用期间需要另一种方法来启动loader.

解决方法

我遇到了同样的问题.在我的情况下,我需要加载’jquery / ui’依赖项.

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐