久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

一旦已經(jīng)存在就更改 Bootstrap 模式選項

Change Bootstrap modal option once it already exists(一旦已經(jīng)存在就更改 Bootstrap 模式選項)
本文介紹了一旦已經(jīng)存在就更改 Bootstrap 模式選項的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在使用 引導(dǎo)模式.我宣布它,我稱之為它,我展示它......一切似乎都很好.

但是,如果我有一個已經(jīng)存在的模式,之前顯示的鍵盤"屬性為 false,我想在旅途中更改它怎么辦?我的意思是:

首先,我創(chuàng)建了一個 Modal 來執(zhí)行此操作(如您所見,我聲明了將鍵盤屬性設(shè)置為 false 的模態(tài)):

$('#myModal').modal({顯示:假,背景:真實,鍵盤:假});

然后我聲明了這個事件處理程序,這意味著如果發(fā)生某事",我希望將鍵盤屬性設(shè)置為 true.

 $('#myModal').on('shown', function(e) {如果(某事){$('#myModal').modal({keyboard: true});}}

所以,我去的時候

$("#myModal").show();

事件處理程序沒有做它應(yīng)該做的事情,因為一旦按下 Escape 鍵我就沒有關(guān)閉模式.但我完全確定某事"是真的,并且我已經(jīng)檢查并重新檢查了 $('#myModal').modal({keyboard: true}) 是否已執(zhí)行.

關(guān)于為什么這不更新配置選項的值的任何線索?

解決方案

要更改已經(jīng)啟動的 Bootstrap 插件的配置設(shè)置,例如 Modal,您需要訪問附加到元素的插件對象,例如 $('#pluginElement').data['somePlugin'] 然后在里面設(shè)置options.

對于模態(tài),您需要:

$('#myModal').data('modal').options.keyboard = true;

JSFiddle 演示(舊)

<小時><塊引用>

對于 Bootstrap 3(如 @Gerald 的評論中所述),您需要 bs.modal:

$('#myModal').data('bs.modal').options.keyboard = true;

等待模式示例

I'm using Bootstrap Modal. I declare it, I call it, I show it...everything seems to be ok.

But what if I have an already existing modal previously shown with "keyboard" property to false and I want to change it on the go? I mean something like:

First, I create a Modal doing this (as you can see, I declare the modal putting keyboard property to false):

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

But then I declare this event handler, that means that if "something" happens, I want the keyboard property to be set to true.

 $('#myModal').on('shown', function(e) {
    if (something){
        $('#myModal').modal({keyboard: true});
    }
 }

So, when I go

$("#myModal").show();

The event handler is not doing what it is supposed to, as I am not getting to close the modal once Escape key is pressed. But I am completely sure that "something" is true and I have checked and re-checked that $('#myModal').modal({keyboard: true}) is executed.

Any clue as to why this isn't updating the value of configuration option?

解決方案

To change configuration settings on already initiated Bootstrap plugin, such as the Modal, you need to access the plugin object attached to the element, like $('#pluginElement').data['somePlugin'] and then set the options in it.

For the Modal, you need:

$('#myModal').data('modal').options.keyboard = true;

JSFiddle Demo (old)


For Bootstrap 3 (as mentioned in comments by @Gerald ), you need bs.modal:

$('#myModal').data('bs.modal').options.keyboard = true;

Waiting Modal Example

這篇關(guān)于一旦已經(jīng)存在就更改 Bootstrap 模式選項的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創(chuàng)建頭像的 jQuery/JavaScript 庫?)
How to do following mask input problem?(如何做以下掩碼輸入問題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設(shè)置值/標(biāo)簽的問題)
how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進(jìn)行單元測試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網(wǎng)站配置偏移量/對齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當(dāng)文本框獲得焦點時選擇所有內(nèi)容)
主站蜘蛛池模板: 亚洲免费在线观看视频 | 天天操网 | 免费国产网站 | 久久激情网 | 亚洲免费小视频 | 国产精品一区二区在线免费观看 | 五月天丁香| 亚洲 欧美 另类 综合 偷拍 | 免费黄视频网站 | 国产在线视频网站 | 91国产丝袜在线播放 | 精品91| 青青草国产成人av片免费 | 日韩综合在线 | 性猛交xxxx富婆老太婆 | 91免费福利视频 | 欧美精品一| 一区二区三区精品 | 一二区视频 | 一级片av| 中文字幕av久久爽av | 亚洲一二区 | 中文在线免费观看 | 激情久久网 | 精品国产成人 | 国产乱淫片视频 | 又色又爽又黄gif动态图 | 不卡av在线 | www.一区 | 夜夜操网站 | 国产精品久久久久久99 | 天天摸夜夜操 | 手机在线免费av | 免费在线观看av | av老司机在线观看 | 久久视频免费 | 欧美日韩在线视频观看 | www.国产在线观看 | 美国一级大黄一片免费中文 | 日韩精品一区二区三区免费视频 | 中文一区二区 |