如何使用Twitter Bootstrap指定多个JavaScript模式参数?

如何使用Twitter Bootstrap指定多个JavaScript模式参数?

问题描述:

我有一个使用Twitter Bootstrap创建的模式.我想用JavaScript打开.现在,我有以下内容:

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>

但是,我也想包括背景和键盘属性. Twitter的文档将选项显示为:

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
})

使用这三个选项的任何组合均无效.我对javascript不太满意,所以我不知道发生了什么.我现在正在阅读javascript教程,看看我哪里出了问题,但到目前为止还算不上运气.

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的模式文档

谢谢.

我对Twitter Bootstrap并不熟悉,但是从快速链接看一下您链接到的引用,就好像.modal()方法正在使用一个对象来指定参数,以便指定多个参数,您应该可以执行以下操作:

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
});

大括号{}中的位是标准的JavaScript对象文字语法,您可以在其中指定多个用逗号分隔的属性.

The bit in the curly brackets {} is standard JavaScript object literal syntax, where you can specify multiple properties separated by commas.