I want to open modal confirmation dialogue and based on that I'm operating some database operation as my need. So please suggest me the best way to open modal confirmation popup that should work even varnish cache or any cache is there.
1 Answer
As refereed by @MichaelHa
Try this Code:
<div id="popup-modal">
<h1> Hi I'm here.... </h1>
</div>
<script>
require(
[
'jquery',
'Magento_Ui/js/modal/modal'
],
function(
$,
modal
) {
var options = {
type: 'popup',
responsive: true,
innerScroll: true,
title: 'popup modal title',
buttons: [{
text: $.mage.__('Continue'),
class: '',
click: function () {
this.closeModal();
}
}]
};
var popup = modal(options, $('#popup-modal'));
$('#popup-modal').modal('openModal');
}
);
</script>
Hope this will help You!!