Hey all,
I'm trying to use a plone mockup modal window on my theme. I can get the modal to display no problem.
I have a 'Close' button within my content on the modal. When a user clicks on that button I would like to set a cookie and close the window but am having no luck targeting that button from js.
For now, I am just trying to fire an alert when that button is pressed. I have a feeling that the modal loads after the rest of the document which is causing my disconnect.
The following html and script loads the modal on page load:
<div id="siteNoticeModal" class="pat-plone-modal" style="display: none" data-pat-plone-modal="width: 400">
<h1 class="documentFirstHeading siteNoticeConsent">site NOTICE AND CONSENT BANNER</h1>
<h3>This is a private site:</h3>
<ul>
<li>some notification</li>
</ul>
<button id="siteNoticeCloseBtn" class="plone-btn plone-btn-success">Close</button>
</div>
<div id="my-modal">
<a href="#siteNoticeModal" style="display:none;" class="plone-btn plone-btn-large plone-btn-primary pat-plone-modal" data-pat-plone-modal="title: site Consent Acknowledgement">Modal basic</a>
</div>
<script>
// on close button click set cookie
$(document).ready(function() {
// if no cookie, fire off modal
if (!Cookies.get('siteCHubNotice')) {
setTimeout(function() {
//$('#my-modal').modal();
$("#my-modal .pat-plone-modal").click();
}, 600);
}
});
</script>
I have tried adding the following to the script but cannot get it to work:
$('#my-modal #siteNoticeCloseBtn').click(function() {
alert('test');
});
Any help would be appreciated. I've tried to read the docs for mockup but do not understand how I would acheive what I am trying to do.
Thanks for your patience.