Trigger Gumby2 Modal Swicth from JavaScript

Sam Deering
Tweet

To trigger Gumby2 Modal switch from JavaScript just add the ‘active’ class to the modal window.

 
jQuery(document).ready(function($) {

    $('.modal#modal-id').addClass('active');

});

My initial thoughts was this way as it’s better programming to use the event handlers for the triggers so it follows the full functionality (it might have other things that it does not just add active to the main modal container). The Gumby2 documentation on switches and toggles is lacking lots of useful code snippets like this.

 
jQuery(document).ready(function($) {

    $('.modal .switch[gumby-trigger="|#modal-id"]:first').trigger(Gumby.click);

});

Related Posts:

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

No Reader comments