I am using the Reveal jQuery plugin. http://www.zurb.com/playground/reveal-modal-plugin
I need to programmatically close the model box when I am done with it, however that feature is not including directly with the plugin.
According to Dave in the comments page,
"The code is in there, just need to hook it up to be called programmatically."
If your modal's id is 'reveal-modal', then just this line will do it:
$('#reveal-modal').trigger('reveal:close');
You can do it a couple of ways.
Trigger a click via jquery on the dismissmodalclass element (defaults to 'close-reveal-modal')
$('.close-reveal-modal').click();
OR
Add this to reveal.js
$.fn.hideModal = function(options){
var self = this,
modal = $(self),
topMeasure = parseInt(modal.css('top'));
$('.reveal-modal-bg').css({'display' : 'none'});
modal.css({'visibility' : 'hidden', 'top' : topMeasure});
}
and use
$('#your_modal_box').hideModal()
The modals class is usually 'reveal-modal'. so changing the lookup to be class based rather than id based, makes this work for more cases:
$('.reveal-modal').trigger('reveal:close');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With