twitter-bootstrap - 使用 .enable-twitter-bootstrap 类在 div 中制作 angular-ui 附加模态

标签 twitter-bootstrap angularjs angular-ui-bootstrap

我们有一个大型站点,其中包含许多遗留 .css,其规则名称与 twitter bootstrap 的规则名称冲突。作为解决方案,我们使用 .sass 版本的 bootstrap 并像这样包装了所有内容:

.bootstrap-enabled {

// Grid system and page structure
@import "vendor/bootstrap-sass/lib/scaffolding";
@import "vendor/bootstrap-sass/lib/grid";
...

因此,如果您想要自举,则必须将您的 html 包装在例如一个<div class="bootstrap-enabled"> -标签。

modals in angular-ui 外,这工作正常因为它们附加到 body .而且我们不能打.bootstrap-enabled从那时起,整个站点将“启用 Bootstrap ”。

有人知道是否可以将 angular-ui 模态附加到 DOM 中的特定元素吗?或者是否有其他智能解决方案可以解决此问题?

最佳答案

我通过将模式和弹出窗口放在命名空间之外来解决它,如下所示:

.bootstrap-enabled {
 ...
}

@import "vendor/bootstrap-sass/lib/modals";
@import "vendor/bootstrap-sass/lib/tooltip";

然后修改 ui-bootstrap-tpls-0.7.0.js 手动添加 bootstrap-enabled 属性到父元素,如下所示:

angular.module("template/modal/backdrop.html", []).run(["$templateCache", function($templateCache) {
  $templateCache.put("template/modal/backdrop.html",
    "<div class=\"tbs-modal-backdrop bootstrap-enabled fade\" ng-class=\"{in: animate}\" ng-style=\"{'z-index': 1040 + index*10}\" ng-click=\"close($event)\"></div>");
}]);

angular.module("template/modal/window.html", []).run(["$templateCache", function($templateCache) {
  $templateCache.put("template/modal/window.html",
    "<div class=\"tbs-modal bootstrap-enabled fade {{ windowClass }}\" ng-class=\"{in: animate}\" ng-style=\"{'z-index': 1050 + index*10}\" ng-transclude></div>");
}]);

关于twitter-bootstrap - 使用 .enable-twitter-bootstrap 类在 div 中制作 angular-ui 附加模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19117977/

相关文章:

angularjs - 如何从 url 中删除 # 标签 MEAN STACK

javascript - 无法使用 Angular 工厂服务获取json数据

javascript - angularjs 选择选择框中的第一个值

jquery - Bootstrap 模式未关闭并刷新索引页面

javascript - 根据相邻元素计算行高

javascript - Bootstrap 模态加载但无响应

angularjs - 如何在 Angular UI Datepicker 中禁用年/月导航

javascript - Bootstrap Navbar(附加导航栏)在滚动期间调整大小

javascript - 观察数组的子值

html - UI Bootstrap 日期选择器未对齐