Skip to content

Conversation

@wmill
Copy link

@wmill wmill commented Aug 30, 2013

.on will work on newly created elements, .bind will not.

This will fix some issues I had using jquery-ui-touch-punch with AngularJS.

Plus, "As of jQuery 1.7, the .on() method is the preferred method for attaching event handlers to a document."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be modernized even more:

    self.element.on({
        'touchstart': $.proxy(self, '_touchStart'),
        'touchmove': $.proxy(self, '_touchMove'),
        'touchend': $.proxy(self, '_touchEnd')
    });

@benjamindeclercq
Copy link

And for removing the event handlers

self.element.off({
'touchstart': $.proxy(self, '_touchStart'),
'touchmove': $.proxy(self, '_touchMove'),
'touchend': $.proxy(self, '_touchEnd')
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants