我试图将元素定位到通过单击TinyMCE按钮创建的模式弹出窗口上。 JQuery的.on()
无效(出于某种原因Plone正在使用JQuery 1.11),而且我也无法在JavaScript中使用委托。就像页面上不存在模式元素一样。
问题可能与TinyMCE将模态放置在<script>
标记之后试图的有关吗?
$(document).ready(function ($) {
document.querySelector('body').addEventListener('click', function (event) {
if (event.target.classList.contains('plone-modal-wrapper')) {
console.log('something');
}
})
})
<html>
<body>
<!-- most of the page here, including the JS script -->
<!-- below is the modal -->
<div class="plone-modal-wrapper" style="z-index: 1041; overflow-y: auto; position: fixed; height: 611px; width: 100%; bottom: 0px; left: 0px; right: 0px; top: 0px;">
<div style="position: absolute; bottom: 0px; left: 0px; right: 0px; top: 0px;">
<div class="plone-modal fade in" style="position: absolute; padding: 20px;">
<div class="plone-modal-dialog" style="margin: 0px; padding: 0px; left: 7.5px; top: 0px;">
<div class="plone-modal-content">
<div class="plone-modal-header"> <a class="plone-modal-close">×</a>
<h2 class="plone-modal-title">Insert Image</h2>
</div>
<div class="plone-modal-body">
<!-- etc -->
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>