WickyNilliams / enquire.js

Awesome Media Queries in JavaScript
http://wicky.nillia.ms/enquire.js/
MIT License
3.63k stars 269 forks source link

Click handler not removed in next media query despite using .unbind() and .off() #148

Closed ghost closed 8 years ago

ghost commented 8 years ago

I believe this is not a personal help request but rather an issue with Enquire. Here is a fiddle describing the issue.

From 0 - 360 px I have a click handler for the ID #menu that slideToggles the .menu-items.

Upon leaving this media query [0 - 360 px] in the unmatch section I have tried to remove the click handler with the unbind as well as off methods but the clicks are still coming through in the next media query [361+ px] where no click handler is assigned.

When resizing to the media query [0 - 360 px] and then back to [361+ px] the clicks are working despite me having removed them in the unmatch part of the [0 - 360 px] media query.

"Travelling across" media queries with a simple resize the click handler does not get removed and keeps active for all media queries.

This leads me to think that somehow once in the range of a media query with a click handler assigned the click handler gets registered outside of Enquire. Being able to really have click handlers only in the selected media query would be awesome.

ghost commented 8 years ago

Solved.

https://stackoverflow.com/questions/13096866/destroying-a-function-when-exiting-a-matched-breakpoint-with-enquire-js

WickyNilliams commented 8 years ago

/me high fives past self

Glad that answer helped you :)

ghost commented 8 years ago

Nick, yes lots, thank you!