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

一旦已經存在就更改 Bootstrap 模式選項

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

問題描述

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

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

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

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

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

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

所以,我去的時候

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

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

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

解決方案

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

對于模態,您需要:

$('#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

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

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

相關文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創建頭像的 jQuery/JavaScript 庫?)
How to do following mask input problem?(如何做以下掩碼輸入問題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進行單元測試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網站配置偏移量/對齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
主站蜘蛛池模板: 91久久久久久久久久久 | 日韩欧美中文 | 日韩高清一区 | 亚洲免费一| 久久中文字幕一区 | 国产午夜亚洲精品不卡 | 成人一区二区三区在线观看 | 欧美一区二区在线播放 | 欧美一区二区在线观看 | 精品91久久 | 99re热精品视频国产免费 | 日韩成人在线观看 | 国产精品国产精品 | 污免费网站 | 天堂va在线观看 | 国产精品成人久久久久 | 国产乱肥老妇国产一区二 | 欧美国产精品一区二区 | 久久久久91 | 久久精品91久久久久久再现 | 日本三级做a全过程在线观看 | 亚洲成年人免费网站 | 国产成人精品a视频一区www | 在线观看亚洲精品 | 国产亚洲高清视频 | 欧美 中文字幕 | 国产精品免费视频一区 | 亚洲欧美日韩在线不卡 | 人人人人干 | 国产97视频在线观看 | 少妇午夜一级艳片欧美精品 | 影音先锋成人资源 | 91精品在线看 | 午夜看电影在线观看 | 91精品国产欧美一区二区 | 成人小视频在线 | 夜夜久久| 久久久精品网站 | 中文字幕精品视频在线观看 | 久热久热| 99riav国产一区二区三区 |