0
我需要攔截Magento 2中Modal彈出窗口的「關閉」事件,但我不知道在哪裏以及如何做。攔截Magento 2中模態功能的事件
這是模板文件中的腳本,它工作的很好,但是,正如我寫的,我需要攔截關閉的事件來停止視頻播放。
<script>
require(
[
'jquery',
'Magento_Ui/js/modal/modal'
],
function ($, modal) {
var options = {
type: 'popup',
responsive: true,
title: $.mage.__('Title Text'),
buttons: [{
text: $.mage.__('Close'),
class: '',
click: function() {
this.closeModal();
var video = document.getElementById("Video1");
video.pause();
}
}]
};
var popup = modal(options, $('#modalVideo'));
$("#modalVideoOpen").on("click", function() {
$('#modalVideo').modal('openModal');
var video = document.getElementById("Video1");
video.play();
});
}
);
</script>