thatcher / env-js

A pure-JavaScript browser environment.
http://www.envjs.com/
464 stars 75 forks source link

jquery live event with default action #10

Closed svenfuchs closed 14 years ago

svenfuchs commented 14 years ago

Suppose I have a document like this one:

  <html>
    <head>
      <title></title>
      <script src="/javascripts/jquery-1.4.2.js" type="text/javascript"></script>
      <script>
        $(document).ready(function() {
          $('a.clickable').live('click', function(event) {
            document.title = 'live click event triggered';
            return false;
          });
        });
      </script>
    </head>
    <body>
      <a href='/foo' class='clickable'>link</a>
    </body>
  </html>

Then the event handler should be called (i.e. document.title set to 'live click event triggered') and the default action of the link (i.e. the request to /foo) should not happen.

What actually happens is: the request to /foo happens first and the event handler is called afterwards.

Jquery registers a live event handler to the topmost dom node, so the handler will be called after the event has bubbled up the entire tree. In envjs 0.3.4 event bubbling seems to happen at the very end of the __dispatchEvent__ method after default actions have been evaluated.

smparkes commented 14 years ago

Given the reference to 0.3.4, it sounds like you're using the Ruby gem? If so, we should move this issue over there (http://github.com/smparkes/env-js/issues). The relevant code has been changed a lot in 1.2 but hasn't been merged into the ruby fork yet.

svenfuchs commented 14 years ago

Yeah, I've just noticed that. I'm talking about the Ruby gem. Was confused about the repositories.

smparkes commented 14 years ago

Sorry for the confusion. Hopefully we get the merge to happen before too long. Did you want to open this on http://github.com/smparkes/env-js/issues? That way you'll get update when it gets changed.

smparkes commented 14 years ago

Thanks!

svenfuchs commented 14 years ago

Ok, I've added the issue over there: http://github.com/smparkes/env-js/issues/issue/9

Will close this one.

Could someone explain what's up with all the forks? Sounds like quite a gap in the version numbers. Does that mean the Ruby gem fork is way behind the original project?

Thanks!

smparkes commented 14 years ago

Right now the Ruby gem rev's don't track the thatcher release numbers. The original fork was based on the thatcher main branch and tracked changes through 1.1. But we weren't doing a lot of releases before 1.2, so I didn't try to sync up the numbers. My plan is that the gem stays 0.* until the merge, then I hope it syncs up to 1.2.*, or whatever is current at the time.

So it's only one minor release behind thatcher, but there's been a lot of work in that minor release.

svenfuchs commented 14 years ago

That makes a lot of sense. Thanks much for the explanation! :)