Prompt widgets in Magento2

The prompt widget source is

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

It also enlarge 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.

Initialize the prompt widgets

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 is initialized
  • Boolean type

Clickable overlay

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

Content

  • Prompt widgets content
  • String type

Title

  • The title of the prompt widgets
  • String type

Event

This prompt widgets executes the following event:

  • Conform
  • Cancel
  • Always

These are some of the prompt widgets in Magento2. I hope this information helps you to prompt widgets in Magento2.

Last Update: April 6, 2018  

February 5, 2018   451   Nandini Ramachandran    Magento2    
Total 4 Votes:
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Reply

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

Facebook
Twitter
INSTAGRAM
LinkedIn