Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To resume, you could try saving the event and re-fire it, setting a flag that can be used to skip the handlers that call suspend() ('confirmAction.fire', in your example).</p> <pre><code>&lt;a href="/somelink/" class="confirm"&gt;Some Link&lt;/a&gt; _________ &lt;script&gt; function bindMethod(self, method) { return function() { method.apply(self, arguments); } } var confirmAction = (function(){ var public = { delayEvent: function(e) { if (e.suspend()) { this.rememberEvent(e); return true; } else { return false; } }, fire: function(e){ if (this.delayEvent(e)) { this.modal(); } }, modal: function(){ showmodal(); yesbutton.onclick = bindMethod(this, this.confirmed); nobutton.onclick = bindMethod(this, this.canceled); }, confirmed: function(){ hidemodal(); this.rememberEvent().resume(); }, canceled: function(){ hidemodal(); this.forgetEvent(); }, rememberEvent: function (e) { if (e) { this.currEvent=e; } else { return this.currEvent; } }, forgetEvent: function () { delete this.currEvent; } } return public; })() // delayableEvent should be mixed in to the event class. var delayableEvent = (function (){ return { suspend: function() { if (this.suspended) { return false; } else { this.suspended = true; this.preventDefault(); return true; } }, resume: function () { /* rest of 'resume' is highly dependent on event implementation, but might look like */ this.target.fireEvent(this); } }; })(); /* 'this' in event handlers will generally be the element the listener is registered * on, so you need to make sure 'this' has the confirmAction methods. */ mixin('a.confirm', confirmAction); attachEvent('a.confirm','click', confirmAction.fire); &lt;/script&gt; </code></pre> <p>This still has potential bugs, such as how it interacts with other event listeners.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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