Created
June 8, 2012 03:53
-
-
Save tsavory/2893463 to your computer and use it in GitHub Desktop.
bind jquary to responsive layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Found the answer in http://drupal.org/node/1299286#comment-5412342 (thanks @bc and @himerus) | |
You can bind to the jQuery global event 'responsivelayout': | |
jQuery('body').bind('responsivelayout', function() { /* handle event */ } ); | |
The global event is defined in omega-mediaqueries.js with $.event.trigger. Because it's global, you can bind a listener to any object in the DOM. | |
So my custom code should look like: | |
(function($) { | |
Drupal.behaviors.myCustomBehavior = { | |
attach: function(context) { | |
$('body').bind('responsivelayout', function(e, d) { | |
if($(this).hasClass("responsive-layout-mobile")) { | |
console.log("a"); | |
} | |
}); | |
}; | |
})(jQuery); | |
Hope this saves someone an hour or like me a day. | |
more resources | |
http://drupal.org/node/1299286#comment-5412342 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment