I have a modal created using Twitter Bootstrap. I want to open using javascript. Right now I have the following:
<script type="text/javascript" id="js">$(document).ready(function() {
$("#my-modal").modal('show')
});
</script>
However, I want to include the backdrop and keyboard attributes as well. Twitter's documentation show the options as:
$('#my-modal').modal({
keyboard: true
})
$('#my-modal').modal({
backdrop: true
})
Using any combination of the three options does not work. I'm not very good with javascript so I don't know what's going on. I'm reading javascript tutorials right now to see where I went wrong, but so far no luck.
Twitter Bootstrap's modal documentation
Thanks.
I'm not familiar with Twitter Bootstrap, but from a quick glance at the reference you linked to it looks like .modal()
method is taking an object to specify parameters so to specify multiple parameters you should be able to do this:
$('#my-modal').modal({
show : true,
keyboard : true,
backdrop : true
});
The bit in the curly brackets {}
is standard JavaScript object literal syntax, where you can specify multiple properties separated by commas.
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