Magento 2.x – Using Confirmation and Alert Jquery Widget popups


In some cases you will need to show a confirmation modal popup, or an alert. To make it Magento way, i will show you some pretty usefull javascript code snippets:

Confirmation popup:

The Magento confirmation widget implements a modal pop-up window with the cancel and confirmation button. You can use it with the following snippet in your javascript code:

Source:  <Magento_Ui_module_dir>/view/base/web/js/modal/confirm.js

 

Alert popup:

The Magento alert widget implements a modal pop-up window with a confirmation button. You can use it with the following snippet in your javascript code:

Source: <Magento_Ui_module_dir>/view/base/web/js/modal/alert.js

 

Before testing, remember to redeploy your static content.

Thanks for reading! Happy coding.!