-
Notifications
You must be signed in to change notification settings - Fork 161
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
Comments
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: |
Hmm. Was just checking this again and now I get undefined for $(document).data('events'); ... |
Just found out that you need to use this for jQuery 1.8+ $._data(document, 'events'); |
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. |
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. |
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). |
Sounds great - thanks for looking into this! |
I guess I've succeeded in editing the parser to make it work with jQuery 1.8+: 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. |
Can you update the main hosted code with my additions? Including the 2 other changes? Thanks in advance, and happy new year! |
Yes - sorry for the long delay! I will try to look at this next week. Been tied up with my DataTables work of late. |
Hi Allan, Have a new predection? :) Kind regards, On Thu, Jan 2, 2014 at 10:10 PM, Allan Jardine notifications@github.comwrote:
|
Yup - whenever I get time - sorry. Completely overwhelmed here... |
Haha. Sounds familiair! Good luck! On Tue, Jan 14, 2014 at 12:34 PM, 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 :-) |
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 On Wed, Jan 15, 2014 at 11:55 AM, 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?...) |
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:
|
Looks like:
Isn't picked up by Visual Event. Assuming its because its attached as a delegate to the document.
The text was updated successfully, but these errors were encountered: