如果您想了解如何处理TwitterBootstrap中的模态关闭事件?和twitter模块的知识,那么本篇文章将是您的不二之选。我们将深入剖析如何处理TwitterBootstrap中的模态关闭事件?
如果您想了解如何处理 Twitter Bootstrap 中的模态关闭事件?和twitter模块的知识,那么本篇文章将是您的不二之选。我们将深入剖析如何处理 Twitter Bootstrap 中的模态关闭事件?的各个方面,并为您解答twitter模块的疑在这篇文章中,我们将为您介绍如何处理 Twitter Bootstrap 中的模态关闭事件?的相关知识,同时也会详细的解释twitter模块的运用方法,并给出实际的案例分析,希望能帮助到您!
本文目录一览:- 如何处理 Twitter Bootstrap 中的模态关闭事件?(twitter模块)
- css – angularjs中的Twitter-Bootstrap下拉列表打开/关闭事件
- css – 造型Twitter Bootstrap模态关闭图标
- twitter-bootstrap – Bootstrap 3.x:点击模态触发器后如何更改网址?
- twitter-bootstrap – Bootstrap 3模态垂直位置中心
如何处理 Twitter Bootstrap 中的模态关闭事件?(twitter模块)
在 Twitter
引导程序中,查看模态文档。我无法弄清楚是否有办法监听模式的关闭事件并执行一个函数。
例如,让我们以这个模态为例:
<div> <button type="button"data-dismiss="modal" aria-hidden="true">×</button> <h3>Modal header</h3></div><div>...</div><div> <a href="#"data-dismiss="modal">Close</a> </div>
顶部的 X 按钮和底部的关闭按钮都可以隐藏/关闭模式,因为data-dismiss="modal"
. 所以我想知道,如果我能以某种方式倾听吗?
或者我可以像这样手动完成,我猜......
$("#salesitems_modal").load(url, data, function() { $(this).modal(''show''); $(this).find(".close_link").click(modal_closing);});
你怎么看?
答案1
小编典典针对 Bootstrap 3 和 4 进行了更新
Bootstrap 3和Bootstrap
4文档引用了两个可以使用的事件。
hide.bs.modal :当调用 hide 实例方法时立即触发此事件。
hidden.bs.modal :当模式对用户完成隐藏时触发此事件(将等待 CSS 转换完成)。
并提供一个如何使用它们的例子:
$(''#myModal'').on(''hidden.bs.modal'', function () { // do something鈥�})
旧版 Bootstrap 2.3.2 答案
Bootstrap 的文档引用了您可以使用的两个事件。
hide :调用 hide 实例方法时立即触发此事件。
hidden :当模式对用户完成隐藏时触发此事件(将等待 css 转换完成)。
并提供了如何使用它们的示例:
$(''#myModal'').on(''hidden'', function () { // do something...})
css – angularjs中的Twitter-Bootstrap下拉列表打开/关闭事件
我成功完成了此操作,但如果下拉列表关闭不是通过选择元素或再次按下标题列表,则箭头不会消失.
(例如,如果我打开一个列表而不打开另一个列表而不关闭第一个列表,则第一个列表的箭头不会消失)
Jsfiddle – http://jsfiddle.net/rpg2kill/uS4Bs/
码:
var myApp = angular.module('myApp',['ui.bootstrap']); function MyCtrl($scope) { $scope.supportedList= ['Option1','Option2','Option3','Option4']; $scope.selectedItem = 'Option1'; } myApp.directive('dropDown',function () { return { restrict: 'E',replace: false,scope: { supportedList:'=',selectedItem:'=' },template: '<div ng-mouseenter="onMouseEntered()" ng-mouseleave="onMouseLeft()">' + '<adata-toggle="dropdown" href="" ng-click="onMouseClicked()" >' + '<img ng-src="http://png.findicons.com/files/icons/2222/gloss_basic/16/arrow_down.png"> </img>' + //Arrow down Icon '<span>{{selectedItem}}</span>' + '</a>' + '<ul>' + '<li ng-repeat="item in supportedList" ng-click="onSelectedItem(item)">' + '{{item}}' + '</li>' + '</ul>' + '</div>',link: function(scope,element,attrs) { scope.dropDownIconVisibility = "hidden"; scope.dropDownIconVisibilityLocked = false; scope.onSelectedItem = function(item) { scope.dropDownIconVisibilityLocked = false; scope.selectedItem = item ; }; scope.onMouseEntered = function() { scope.dropDownIconVisibility = "visible"; }; scope.onMouseLeft = function() { if (scope.dropDownIconVisibilityLocked) return; scope.dropDownIconVisibility = "hidden"; }; scope.onMouseClicked = function() { scope.dropDownIconVisibility = "visible"; scope.dropDownIconVisibilityLocked = !scope.dropDownIconVisibilityLocked; }; } }; })
代码有点难看.更好的解决方案是在鼠标悬停或列表打开时显示箭头,但我不知道如何将角度绑定到下拉列表的状态.
有没有办法将角度绑定到Twitter bootstrap的下拉事件?
或者有更好的方法来解决这个问题吗?
解决方法
删除所有鼠标跟踪代码,只添加两个CSS规则和here you go:
a.dropdown-toggle img { visibility: hidden; } a.dropdown-toggle:hover img { visibility: visible; }
css – 造型Twitter Bootstrap模态关闭图标
.modal-header .close { float: right !important; margin-right: -30px !important; margin-top: -30px !important; background-color: white !important; border-radius: 15px !important; width: 30px !important; height: 30px !important; opacity: 1 !important; }
它在Chrome / IE上运行得相当不错,但有时在Firefox上我会遇到奇怪的行为(附图像).是否还有其他CSS规则供我在Firefox上使用此工作?
解决方法
twitter-bootstrap – Bootstrap 3.x:点击模态触发器后如何更改网址?
我有一个使用url domain.com/companies的网页
这是我在该网页中模式的触发器.
<a href="#modal-add-company"data-toggle="modal"><i></i> New Company</a>
这将成功触发此模态
<div id="modal-add-company"tabindex="-1" role="dialog" aria-hidden="true">
但是,该网址不会更改为domain.com/companies#modal-add-company
url domain.com/companies#modal-add-company也不会在重新加载时触发模态.
如何进行以下操作我需要做什么:
>每当我触发模态并显示模态时,将URL更改为domain.com/companies#modal-add-company,并且
>如果我直接输入url domain.com/companies#modal-add-company,则显示模态
解决方法
$(document).ready(function(){ $(window.location.hash).modal('show'); $('a[data-toggle="modal"]').click(function(){ window.location.hash = $(this).attr('href'); }); });
假设您有一个触发器来关闭模态,如下所示:
<button type="button"data-dismiss="modal" aria-hidden="true">×</button>
您可以在上面的代码块下面添加:
$('button[data-dismiss="modal"]').click(function(){ var original = window.location.href.substr(0,window.location.href.indexOf('#')) history.replaceState({},document.title,original); });
并且假设您希望转义按钮仍然能够关闭模态,并且还更改URL,整个代码块将如下所示:
$(window.location.hash).modal('show'); $('a[data-toggle="modal"]').click(function(){ window.location.hash = $(this).attr('href'); }); function revertToOriginalURL() { var original = window.location.href.substr(0,window.location.href.indexOf('#')) history.replaceState({},original); } $('.modal').on('hidden.bs.modal',function () { revertToOriginalURL(); });
感谢https://stackoverflow.com/a/13201843/80353关于如何使用模态关闭事件.
twitter-bootstrap – Bootstrap 3模态垂直位置中心
>当你不知道模态的确切高度时,如何将模态垂直放在中心?
>是否可能有模态中心和溢出:auto在模态体,但只有模态超过屏幕高度吗?
我已经尝试使用这:
.modal-dialog { height: 80% !important; padding-top:10%; } .modal-content { height: 100% !important; overflow:visible; } .modal-body { height: 80%; overflow: auto; }
这给了我所需要的结果,当内容远大于垂直屏幕尺寸,但对于小模态内容,它是非常不可用。
解决方法
.modal { text-align: center; } @media screen and (min-width: 768px) { .modal:before { display: inline-block; vertical-align: middle; content: " "; height: 100%; } } .modal-dialog { display: inline-block; text-align: left; vertical-align: middle; }
并调整一点点.fade类,以确保它出现在窗口的顶部边框之外,而不是中心
今天关于如何处理 Twitter Bootstrap 中的模态关闭事件?和twitter模块的介绍到此结束,谢谢您的阅读,有关css – angularjs中的Twitter-Bootstrap下拉列表打开/关闭事件、css – 造型Twitter Bootstrap模态关闭图标、twitter-bootstrap – Bootstrap 3.x:点击模态触发器后如何更改网址?、twitter-bootstrap – Bootstrap 3模态垂直位置中心等更多相关知识的信息可以在本站进行查询。
本文标签: