【发布时间】:2020-02-07 10:39:44
【问题描述】:
我将 .draggable() 放在了我的模态框上,但它们仅适用于第二次调用。 模态是从服务文件中调用的。
服务文件:
function callWarningModalService(data) {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: vm.constants.WARNING,
controller: vm.constants.WARNING_CONTROLLER,
backdrop: vm.BACKDROP,
resolve: {
params: function () {
return data;
}
}
});
$timeout(function () {
$(".modal-content").draggable({ handle: ".modal-header" });
}, 10);
return modalInstance;
}
在Controller文件中调用modalService的callWarning()内部:
modalService.callWarningModalService(vm.params).result.then(function (data) {
if (data !== vm.constants.CANCEL) {
vm.isDocumentAction = data;
}
});
所以是的,作为测试,我将模式调用从服务移动到控制器文件,但显示了相同的结果。
Controller 文件中的 callWarning() 内部
modal.message = vm.constants.WARNING_MESSAGE;
var modalInstance = $uibModal.open({
animation: true,
templateUrl: vm.constants.WARNING,
controller: vm.constants.WARNING_CONTROLLER,
backdrop: vm.BACKDROP,
resolve: {
params: function () {
return modal;
}
}
});
$timeout(function () {
$(".modal-content").draggable({ handle: ".modal-header" });
}, 10);
modalInstance.result.then(function () { });
我尝试在 chrome 开发工具上对其进行调试,它首先调用 jquery-ui-draggable,然后使用完全相同的模式调用后续模式。
有没有办法让模态框在第一次调用时就可以拖动? 为什么你认为它在第一次调用时不起作用?
【问题讨论】:
标签: javascript jquery angularjs jquery-ui jquery-ui-draggable