How to Prompt widgets in Magento 2 platform?

Learn how to prompt the widgets in Magento 2 platform with hassle-free steps in this blog.

The prompt widget source is

<Magento_Ui_module_dir>/view/base/web/js/modal/prompt.js 

It also enlarges the Magento model widgets:

The design pattern for the model pop-up windows in the administration is explained in the Magento admin Pattern Library, Slide-Out Panel, Modal Window, Overlays Topics.

Get A Fully-Optimized E-commerce Shopping Experience For You!!!

Initialize the prompt widgets in Magento 2

The prompt widgets can be initialized with or without binding to a certain component.

Initialization on an element
('#prompt_init').prompt({

    title: 'Prompt title',

    actions: {

        confirm: function(){}, //callback on 'Ok' button click

        cancel: function(){}, //callback on 'Cancel' button click

        always: function(){}

    }

});
Standalone initialization
 require([

    'Magento_Ui/js/modal/prompt'

], function(prompt) { // Variable that represents the `prompt` function

 prompt({

        title: 'Some title',

        content: 'Some content',

        actions: {

            confirm: function(){},

            cancel: function(){},

            always: function(){}

        }

    });

 

});

 There are some options in prompt widgets which you can use

Action

  • Widgets call back
  • Object type

Auto open

  • automatically open prompt widgets when the widgets are initialized
  • Boolean type

Clickable overlay

  • Close the prompt widgets when the user clicks on the overlay
  • Boolean type

Content

  • Prompt widgets content
  • String type

Title

  • The title of the prompt widgets
  • String type

Event

These prompt widgets execute the following event:

  • Confirm
  • Cancel
  • Always

These are some prompt widgets in Magento 2. I hope this information helps you to prompt widgets.

Prompt widgets in Magento 2


Posted

in

, ,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *