最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I specify multiple javascript modal parameters with Twitter Bootstrap? - Stack Overflow

programmeradmin1浏览0评论

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 bination 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 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 bination 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.

Share Improve this question edited Nov 19, 2011 at 21:46 crftr 8,5464 gold badges36 silver badges45 bronze badges asked Oct 29, 2011 at 7:01 Jonathan OngJonathan Ong 20.4k18 gold badges82 silver badges118 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

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 mas.

发布评论

评论列表(0)

  1. 暂无评论