5

Grid xml column:

<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'); }, }); 

Used showLoader: true and var body = $('body').loader(); body.loader('show'); but unable to start loader while ajax request.

Need an alternative to start loader during ajax call.

6 Answers 6

0

I faced the same issue. In my case, I need to load the 'jquery/ui' dependency.

define( [ 'jquery', ... 'jquery/ui' 
Sign up to request clarification or add additional context in comments.

2 Comments

Try to clear cache, and put jquery/ui as the last dependency.
Tried but same issue.
0

Please have a look at the below code which might help.

define([ 'jquery', 'Magento_Checkout/js/model/full-screen-loader', ], function ($,fullScreenLoader ) { //Start Loader fullScreenLoader.startLoader(); //Your AJax COde here //Stop Loader fullScreenLoader.stopLoader(); }); 

Comments

0

Just add the loader dependency to the end:

define([ 'jquery', ... 'loader' ] 

showLoader: true and var body = $('body'); body.loader('hide'); will start working.

Comments

0

Try $('body').trigger('processStart') & $('body').trigger('processStop')

Comments

0

Because you using async: false try to refactor you code to change logic async: true ajax call

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

In your JavaScript code that handles the row action, use the uiElement.loading to show and hide the loader during the AJAX call.

If you're working on a custom JS component that handles the action, you can do something like this:

js

define([ 'jquery', 'mage/url', 'mage/loader' ], function ($, urlBuilder) { 'use strict';

return function (rowData) { // Show loader before making the AJAX call $('body').loader('show'); $.ajax({ url: urlBuilder.build('your_module/controller/action'), data: {row_id: rowData.row_id}, // Adjust your data as needed type: 'POST', success: function (response) { // Process response }, error: function () { // Handle error }, complete: function () { // Hide loader when the AJAX call completes $('body').loader('hide'); } }); }; }); 

This will show the default Magento loader when the AJAX call starts and hide it when the call is complete.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.