Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery document delegated events aren't picked up #33

Closed
DataTables opened this issue Nov 7, 2013 · 17 comments
Closed

jQuery document delegated events aren't picked up #33

DataTables opened this issue Nov 7, 2013 · 17 comments

Comments

@DataTables
Copy link
Collaborator

Looks like:

$(document).on('click', '#Button_Email', function(event) { });

Isn't picked up by Visual Event. Assuming its because its attached as a delegate to the document.

@KoalaBear84
Copy link
Contributor

I see that you can access this with the following code, at least for the delegated events for 'document' which I always use:

$(document).data('events');

Still need to find a good way to get all 'data' for 'events' for all tags.. It also looks like you cannot do this the same for every jQuery version:
http://bugs.jquery.com/ticket/10589

@KoalaBear84
Copy link
Contributor

Hmm. Was just checking this again and now I get undefined for $(document).data('events'); ...

@KoalaBear84
Copy link
Contributor

Just found out that you need to use this for jQuery 1.8+

$._data(document, 'events');

@KoalaBear84
Copy link
Contributor

I think this will list all events added with jQuery. The 'old' / normal ones, and the delegated ones with the .on().

$(document).each(function(index1, element) {
  var events = $._data(element, 'events');

  if (events !== undefined) {
    $.each(events, function(index2, eventtypes) {
      $.each(eventtypes, function(index3, event) {
        //console.log(event);
        console.log('delegated ' + event.type + ' on ' + event.selector);
      });
    });
  }
});
$('*').each(function(index1, element) {
  var events = $._data(element, 'events');

  if (events !== undefined) {
    $.each(events, function(index2, eventtypes) {
      $.each(eventtypes, function(index3, event) {
        //console.log(element);
        //console.log(event);
        console.log(event.type + ' on ' + element.nodeName + ', element #' + $(element).index('*') + ' in DOM');
      });
    });
  }
});

Now only 'merge' this with the current code. I dont know if there already is a loop over all elements in the code where we can add this so it will not get much slower than now.

I also see that none of the events listed with these loops are currently returned by Visual Event 1 and 2. That's why it has gotten useless for me. :P

Maybe the author can integrate? Else I will look another time if I can add it.

@KoalaBear84
Copy link
Contributor

Maybe you can do something like this:

var events = $._data(element, 'events') || $.fn('events');

This way the new jQuery 1.8+ method will be used first, and as fallback the old method.

@KoalaBear84
Copy link
Contributor

I finally succeeded in integrating this into Visual Event. It's not yet pretty because I had to change the jQueryGeneric method a bit, to make it work with the old and new method without completely duplicating 90% of the method.

Can't continue now, but will 'redo' it better and then see how to contribute on Github (first time).

@DataTables
Copy link
Collaborator Author

Sounds great - thanks for looking into this!

@KoalaBear84
Copy link
Contributor

I guess I've succeeded in editing the parser to make it work with jQuery 1.8+:
#34

Please review and 'merge' or how that works here on GitHub.

Also please look the other 2 welcome changes. And after that, please compile and place the new version on website.

@KoalaBear84
Copy link
Contributor

Can you update the main hosted code with my additions?

Including the 2 other changes?

Thanks in advance, and happy new year!

@DataTables
Copy link
Collaborator Author

Yes - sorry for the long delay! I will try to look at this next week. Been tied up with my DataTables work of late.

@KoalaBear84
Copy link
Contributor

Hi Allan,

Have a new predection? :)

Kind regards,
Bas

On Thu, Jan 2, 2014 at 10:10 PM, Allan Jardine notifications@github.comwrote:

Yes - sorry for the long delay! I will try to look at this next week. Been
tied up with my DataTables work of late.


Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-31484924
.

@DataTables
Copy link
Collaborator Author

Yup - whenever I get time - sorry. Completely overwhelmed here...

@KoalaBear84
Copy link
Contributor

Haha. Sounds familiair! Good luck!

On Tue, Jan 14, 2014 at 12:34 PM, Allan Jardine notifications@github.comwrote:

Yup - whenever I get time - sorry. Completely overwhelmed here...


Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-32257575
.

@DataTables
Copy link
Collaborator Author

Brilliant fix - thanks for this. I've just pull it in, and your other changes and it appears to work very well. I've made a number of other changes such as adding jQuery 1.10 support and I'll be deploying the updates shortly.

Sorry for the delay in getting this in :-)

@KoalaBear84
Copy link
Contributor

Haha. You're welcome.

Thanks for the 'merging' and hope to see it soon on 'production'.

Our lives these days can get very busy easily.. :)

Is there some sort of newsletter of update mail? Or how will I know it's
live?

On Wed, Jan 15, 2014 at 11:55 AM, Allan Jardine notifications@github.comwrote:

Brilliant fix - thanks for this. I've just pull it in, and your other
changes and it appears to work very well. I've made a number of other
changes such as adding jQuery 1.10 support and I'll be deploying the
updates shortly.

Sorry for the delay in getting this in :-)


Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-32351555
.

@DataTables
Copy link
Collaborator Author

It should be live now - although it is possibly you might need to clear your browser's cache if it has bookmarked the loader.

There isn't an update feed for Visual Event at the moment. its not really a popular enough library to warrant that (yet?...)

@KoalaBear84
Copy link
Contributor

Ok, thanks.

It should be more popular! Very handy sometimes! :)

I understand that you do not have it, no problem.

On Wed, Jan 15, 2014 at 12:08 PM, Allan Jardine notifications@github.comwrote:

It should be live now - although it is possibly you might need to clear
your browser's cache if it has bookmarked the loader.

There isn't an update feed for Visual Event at the moment. its not really
a popular enough library to warrant that (yet?...)


Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-32352323
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant