0

I have the following code:

$('.uiModalWrapper').live('click', function() {

                            var modal = $(this).find('.uiModal');

                            modal.addClass('shake');

                            modal.addEventListener('webkitAnimationEnd', function() {

                                modal.removeClass('shake');

                            });


                        });

Which should add a class called shake to an element when it's clicked and then remove it again when the webkitAnimationEnd event takes place. However it causes an error Uncaught TypeError: Object [object Object] has no method 'addEventListener'

Any ideas on how to fix this? Thanks

Cameron
  • 27,963
  • 100
  • 281
  • 483

3 Answers3

1

modal is a jQuery object, not a DOM element. It doesn't have addEventLister, it has the jQuery stuff for adding listeners (on?).

Dagg Nabbit
  • 75,346
  • 19
  • 113
  • 141
0

you could get the modal element just with var modal = $('.uiModal'); and then you can work with the DOM element

msonsona
  • 1,306
  • 14
  • 20
  • 2
    That would get _all_ ".uiModal" elements, not just the ones inside the clicked ".uiModalWrapper" element, and it would still be a jQuery object - need to say `modal[0]` to work with the (first) DOM element. – nnnnnn Mar 12 '12 at 01:37
0

This solves the problem: Is there a callback on completion of a CSS3 animation?

Seems using BIND will do the trick.

Community
  • 1
  • 1
Cameron
  • 27,963
  • 100
  • 281
  • 483