How to specify multiple javascript modal parameters using twitter bootstrap?

I have a modal created using Twitter Bootstrap. I want to open using javascript. Now I have the following:

<script type="text/javascript" id="js">$(document).ready(function() { $("#my-modal").modal('show') }); </script> 

However, I want to also include background and keyboard attributes. Twitter documentation contains the following options:

 $('#my-modal').modal({ keyboard: true }) $('#my-modal').modal({ backdrop: true }) 

Using any combination of the three parameters does not work. I am not very good at javascript, so I don’t know what is going on. I am reading javascript tutorials right now to see where I did wrong, but so far no luck.

Twitter Trendy Bootstrap Documentation

Thanks.

+4
source share
1 answer

I am not familiar with Twitter Bootstrap, but with a quick look at the link you are linked to, it looks like this: the .modal() method takes an object to specify parameters, so to specify several parameters you should do this:

 $('#my-modal').modal({ show : true, keyboard : true, backdrop : true }); 

A bit in braces {} is the standard literal syntax for a JavaScript object, where you can specify multiple properties, separated by commas.

+8
source

All Articles