From 78337eeed282083b2dc93d75f86401bc577e1027 Mon Sep 17 00:00:00 2001 From: Robbert Merlier Date: Wed, 4 Nov 2015 13:34:22 +0100 Subject: [PATCH] fix(modal): cannot append to element outside of document - needed for appending modal's outside of an iframe --- src/modal/modal.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modal/modal.js b/src/modal/modal.js index e99a5cc9a0..637bab1992 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -281,7 +281,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap']) function removeModalWindow(modalInstance, elementToReceiveFocus) { var modalWindow = openedWindows.get(modalInstance).value; - var appendToElement = $document.find(modalWindow.appendTo).eq(0); + var appendToElement = modalWindow.appendTo; //clean up the stack openedWindows.remove(modalInstance); @@ -424,7 +424,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap']) openedClasses.put(modalBodyClass, modalInstance); - var appendToElement = $document.find(modal.appendTo).eq(0), + var appendToElement = modal.appendTo, currBackdropIndex = backdropIndex(); if (!appendToElement.length) { @@ -565,8 +565,8 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap']) backdrop: true, //can also be false or 'static' keyboard: true }, - $get: ['$injector', '$rootScope', '$q', '$templateRequest', '$controller', '$uibModalStack', - function ($injector, $rootScope, $q, $templateRequest, $controller, $modalStack) { + $get: ['$injector', '$rootScope', '$q', '$document', '$templateRequest', '$controller', '$uibModalStack', + function ($injector, $rootScope, $q, $document, $templateRequest, $controller, $modalStack) { var $modal = {}; function getTemplatePromise(options) { @@ -614,7 +614,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap']) //merge and clean up options modalOptions = angular.extend({}, $modalProvider.options, modalOptions); modalOptions.resolve = modalOptions.resolve || {}; - modalOptions.appendTo = modalOptions.appendTo || 'body'; + modalOptions.appendTo = modalOptions.appendTo || $document.find('body').eq(0); //verify options if (!modalOptions.template && !modalOptions.templateUrl) {