Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery simplemodal unable to call another function
    text
    copied!<p>In my modal window I have a "continue" button. Whilst I can get the modal to close by assigning the button with the simplemodal-close class, I can't get it to call my function. I've put together this code from the simple demos on the site.</p> <p>The button:</p> <pre><code>&lt;a href="#" class="simplemodal-close" onClick="closePopup()"&gt;&lt;img src="bell/images/button_understand.gif" width="116" height="49"&gt;&lt;/a&gt; </code></pre> <p>the javascript:</p> <pre><code>$(document).ready(function() { function showPopups(){ var e = document.getElementById('hirpopup'); $('#hirpopup').modal({ opacity:80, overlayCss: {backgroundColor:"#fff"} }); e.style.display = 'block'; return false; } function closePopup(){ var e = document.getElementById('hirpopup'); e.style.display = 'none'; confirm(function () { sameWindow(this.form); }); } function confirm(callback) { $('#hirpopup').modal({ onShow: function () { var modal = this; // call the callback if ($.isFunction(callback)) { callback.apply(); } } }); } }); </code></pre> <p>Any ideas as I'm pretty new to jQuery and completely new to simplemodal.</p> <p>EDIT: I've updated my javascript as follows, however its still not doing my function. I get the alert of 1, and the alert with the function in it but nothing else.</p> <pre><code>$(document).ready(function(){ $("#close").css("cursor", "pointer"); $('#next').click(function(){ var e = document.getElementById('hirpopup'); $('#hirpopup').modal({ opacity:80, overlayCss: {backgroundColor:"#fff"} }); e.style.display = 'block'; return false; }); $('#close').click(function(){ var e = document.getElementById('hirpopup'); e.style.display = 'none'; confirm(function () { sameWindow(this.form); }); }); }); function confirm(callback) { alert("1"); alert(callback); $('#hirpopup').modal({ onShow: function () { alert("2"); var modal = this; // call the callback if ($.isFunction(callback)) { alert("3"); callback.apply(); } } }); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload