久久久久久久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 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
主站蜘蛛池模板: 久久夜色精品国产 | 一级片在线播放 | 午夜小电影 | av在线免费观看网站 | 精品国产乱码久久久久久丨区2区 | 亚洲精品日韩一区二区电影 | 中文字幕在线观看一区二区 | 中文字幕国产精品 | 91国自视频 | 尤物在线精品视频 | 免费在线观看黄色av | 国产成在线观看免费视频 | 国产乱xxav | 国产日韩精品久久 | japan21xxxxhd美女| 免费国产视频在线观看 | 观看av | 欧美videosex性极品hd | 亚洲网站在线观看 | 国产欧美精品一区二区 | 欧美日韩精品专区 | 成年人在线观看 | 欧美精品v | 91在线精品一区二区 | 久久99网站 | 久久久久九九九女人毛片 | 在线观看免费福利 | 国产精品国产a级 | 亚洲精品成人av久久 | 在线国产小视频 | 亚州春色| www.久| 中文字幕在线一区二区三区 | 一区二区免费 | 亚洲一区二区三区四区五区中文 | 激情毛片 | 精品国产欧美 | 亚洲天堂精品一区 | 日韩视频一区二区三区 | 国产精品久久久久久婷婷天堂 | 99福利视频导航 |