将 UI 模式对话框添加到新的 DIV 标记
UI modal dialog getting added to a new DIV tag
这对你们来说可能是一个简单的问题,但对于像我这样的新手来说,这真的很困难。我有几个通过 ng-repeat 创建的div,当我单击div 时,我希望看到一个包含一些内容的模态窗口。现在我能够让弹出窗口和数据工作,但是它不是显示在div 中的模态窗口,而是创建自己的div。我将模态窗口用作单独的模块,并将其注入到我的控制器中。
主应用控制器
var app = angular.module('MainApp', ['ngRoute','ui.bootstrap','mddmodal']);
app.controller('MddController',function ($scope, $interval, $modal, $log) {
$scope.showInfo = function (index) {
var exchangeCode = $scope.entries[index];
console.log( ">>>>>>> showInfo " + index );
$scope.open( 'sm', index );
}
$scope.hideInfo = function (index) {
var exchangeCode = $scope.entries[index];
/*$scope.modalInstance.dismiss('cancel');*/
}
$scope.items = [];
$scope.open = function (window_size, index ) {
console.log("Clicked on open +++++ " + window_size + " index " + index );
$scope.items.push( "index" + index );
$scope.modalInstance = $modal.open({
templateUrl: 'scripts/controllers/_mdd_modal_impl.html',
controller: 'ModalInstanceCtrl',
size: window_size,
resolve: {
items: function () {
return $scope.items;
}
}
});
};
局部视图
<div class="padding-from-sides" >
<div class="row top-buffer" ng-show="dataLoaded">
<div ng-repeat="entry in entries" ng-model="entry" class="col-md-1" ng-click="showInfo($index)" ng-mouseleave="hideInfo($index)">
<!--{{entry.errors}}-->
<div square-draw component-id="entry.exchangeCode" component-name="entry.exchangeName" ></div>
</div>
</div>
</div>
</div>
模态网页
<body ng-app='mddmodal'>
<div>
<div class="modal-header">
<h3 class="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body">
<table>
<tr>
<td ng-repeat="item in items">
<li>
<a ng-click="selected.item = item">{{ item }}</a>
</li>
</td>
</tr>
</table>
Selected: <b>{{ selected.item }}</b>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
<!-- <div ng-show="selected">Selection from a modal: {{ selected }}</div>-->
</div>
</body>
模态 JS
var mdd_modal = angular.module('mddmodal',['ui.bootstrap']);
mdd_modal.controller('ModalInstanceCtrl', function ($scope, $modalInstance, items) {
$scope.items = items;
$scope.selected = {
item: $scope.items[0]
};
$scope.ok = function () {
$modalInstance.close($scope.selected.item);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
});
我现在面临的问题是模态的弹出窗口是在 ng-repeatdiv 之外创建的,我如何控制模态以便我可以在 ng-repeatdiv 内获取模态。
例如:
<ng repeat div>
one entry of the square draw directive
modal on click
<close div>
提前感谢!
第三方应用程序擅长将东西放在意想不到的地方。 我使用第三方弹出窗口 (ColorBox) 来创建它工作所需的 2 个div,但是在 ASP.NET Web 应用程序中,它将这些元素放在表单之外。 因此,为了使代码正常工作,我必须根据他们的常见问题添加此内容,以重新定位有问题的div:
$(document).ready(function () {
$("#colorbox, #cboxOverlay").appendTo('form:first');
});
类似的东西可能对你有用。
相关文章:
- 如何将DIV标记的内容拆分为多个DIV
- 如何使用Jquery在DIV标记内创建表
- 在 DIV 标记中动态加载页面
- 小程序上的Div标记
- 如何使JavaScript只在特定的DIV标记中起作用
- 从一个正在运行的PHP代码中,了解如何更新DIV标记中的状态
- For循环只打印一个DIV标记.不是8个DIV标签
- 如果文本为 0,JavaScript 隐藏 DIV 标记
- 将 UI 模式对话框添加到新的 DIV 标记
- 使用 jquery 跟踪 DIV 标记下的 HTML 表单控件中的数据更改
- 计算没有名称或 ID 的通用 DIV 标记
- 如何使用 AJAX 打开 DIV 标记内的 URL
- Div 标记不显示任何结果
- 我可以从子跨度点击事件中获得父Div标记innerHTML吗?请参阅代码
- DIV标记滚动时出错
- 如何使用注入WKWebView的Javascript替换DIV标记中只有类无id的文本
- 向DIV标记追加文本/元素
- 嵌套的DIV标记
- 如何使用javascript访问Div标记的内部文本
- Div标记目标属性