Я пытаюсь настроить таргетинг на элемент в модальном всплывающем окне, которое создается нажатием кнопки TinyMCE..on()
в JQuery не работает (и 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>