Snæ*_*ørn 6 html5 internet-explorer modal-dialog angularjs angular-ui-bootstrap
在IE中使用自动对焦时,我遇到光标放置问题.图像应清楚地显示问题.

幸运的是,我已经能够在一个plunker中重现这一点.我已经把它剥离到了必需品,所以应该很容易看到发生了什么.
我如何使IE表现?
AngularJS(也可用于plunker)
app.directive('autofocus', [
'$timeout', function($timeout) {
return function(scope, elem, attr) {
scope.$on('autofocus', function(e) {
$timeout(function() {
elem[0].focus();
});
});
};
}
]);
/* http://stackoverflow.com/questions/14833326/how-to-set-focus-in-angularjs */
app.factory('autofocus', ['$rootScope', '$timeout', function($rootScope, $timeout) {
return function() {
$timeout(function() {
$rootScope.$broadcast('autofocus');
});
};
}]);
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('main', {
url: '/main'
});
}]);
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('main.modal', {
url: '/modal',
onEnter: ['$state', '$stateParams', '$modal', 'autofocus',
function ($state, $stateParams, $modal, autofocus) {
var instance = $modal.open({
templateUrl: 'modal.html'
});
instance.result.then(function () {
// OK
// GOTO parent state
$state.go('^');
}, function () {
// Cancel
// GOTO parent state
$state.go('^');
});
instance.opened.then(function() {
autofocus();
});
}
]
});
}]);
Run Code Online (Sandbox Code Playgroud)
标记
<form>
<div class="modal-header">
<h3 class="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body">
<input type="text" name="foo" autofocus>
<br>
<input type="text" name="bar">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">OK</button>
<button type="button" class="btn btn-warning" ng-click="$dismiss()">Cancel</button>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
iva*_*ash 11
感谢您记录此问题并进行诊断.这是我能找到的关于这一点的唯一主题,这似乎是一个经常出现的问题.这个脚本是不是有点矫枉过正?
解决问题的css溶解::
.modal.fade {
transition:opacity .3s linear;
}
Run Code Online (Sandbox Code Playgroud)
它会有效杀死幻灯片,但会留下淡入淡出效果.
小智 6
看起来我可能是"幻灯片" - 动画应该受到指责.我设法通过强制模态淡入而不滑动来修复此问题,方法是添加"windowClass:modal fade in",如下所示:
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('main.modal', {
url: '/modal',
onEnter: ['$state', '$stateParams', '$modal', 'autofocus',
function ($state, $stateParams, $modal, autofocus) {
var instance = $modal.open({
templateUrl: 'modal.html',
windowClass: 'modal fade in'
});
instance.result.then(function () {
// OK
// GOTO parent state
$state.go('^');
}, function () {
// Cancel
// GOTO parent state
$state.go('^');
});
instance.opened.then(function() {
autofocus();
});
}
]
});
}]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2294 次 |
| 最近记录: |