Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

jQuery .on() not firing in real-time view. #148

Closed
phuu opened this Issue · 3 comments

2 participants

Tom Ashworth Remy Sharp
Tom Ashworth
Owner

jQuery .on() events will not fire in real time view, but will in render view.

Include jQuery 1.7 or later. Example code fails:

$(function () {
  $('body').on('click', function (e) {
    alert("Hello.");
  });
});

-- RS edit --

Example link: http://jsbin.com/ufelah/7

Remy Sharp
Owner

Issue with ready event firing before the iframe is done. Already handles $(document).ready - probably need to add the same hack in place.

Remy Sharp
Owner

Okay, so the live render never shows you alerts, prompts or confirm boxes - because it re-renders as you type, an alert box firing all the time would interrupt the development flow. The "render" button does include alerts because you're triggering it.

So in fact it's on purpose that the alert doesn't work - so technically a feature!

However, it does give me an idea - I could nuke all alerts loading and then re-introduce the alert method once render is complete so that if you interact with the preview, it'll still fire alerts.

I'm not 100% about this, but I'll try it out in the jsbin beta: http://jsbin.com/3/ - it'll be live in a few minutes....

Remy Sharp remy closed this
Remy Sharp
Owner

Working example of where the alerts are removed during load, but re-instantiated once all user code is complete: http://jsbin.com/3/ufelah/10/edit?html,javascript,live

Remy Sharp remy referenced this issue from a commit
Remy Sharp remy Remove alerts only during load - put them back in to allow user to in…
…teract and get alerts. Fixes #148
6d765fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.