我正在尝试使用 Magento 2 Modal Widget,如下所示,但它不起作用。它也没有显示任何错误。
<script>
require(
[
'jquery',
'Magento_Ui/js/modal/modal'
],
function(
$,
modal
) {
$("#ship_now").click(function() {
$('#shipNowContent').modal({
autoOpen:false,
clickableOverlay:true,
type:'popup',
title:'Hello',
});
});
}
);
</script>
有人可以在这方面帮助我吗?
最佳答案
试试这个,对我来说效果很好。 在 Magento 2.0 中实现。
<button type="button" id="openModel" class="btn btn-primary">Open Model</button>
<div id="myModel">
<h1>Title</h1>
<div>Content.....</div>
</div>
<script>
require(
[
'jquery',
'Magento_Ui/js/modal/modal'
],
function($,modal) {
var options = {
type: 'popup',
responsive: true,
innerScroll: true,
title: 'popup mpdal title',
buttons: [{
text: $.mage.__('Continue'),
class: '',
click: function () {
this.closeModal();
}
}]
};
var popup = modal(options, $('#myModel'));
$("#openModel").on("click",function(){
$('#myModel').modal('openModal');
});
}
);
</script>
关于jquery - Magento 2 模态小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36371882/