Skip to content

Commit

Permalink
fix(modal): Fix removing modal from DOM on .remove(), closes #755
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Bradley committed Mar 10, 2014
1 parent 41afcdc commit c4ca7a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions js/ext/angular/src/service/ionicModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv

$timeout(function(){
element.addClass('ng-enter-active');
self.scope.$parent.$broadcast('modal.shown');
self.scope.$parent && self.scope.$parent.$broadcast('modal.shown');
}, 20);

self._deregisterBackButton = $ionicPlatform.registerBackButtonAction(function(){
Expand Down Expand Up @@ -65,7 +65,8 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv

$timeout(function(){
self.scope.$destroy();
}, 500);
self.el && self.el.parentElement && self.el.parentElement.removeChild(self.el);
}, 1000);
},

isShown: function() {
Expand Down
14 changes: 7 additions & 7 deletions js/ext/angular/test/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<div class="modal" ng-controller="ModalCtrl">
<header class="bar bar-header bar-assertive">
<h1 class="title">New Contact</h1>
<button class="button button-clear button-primary" ng-click="close()">Cancel</button>
</header>
<ion-content has-header="true">
<div class="padding">
Expand All @@ -43,7 +42,8 @@ <h1 class="title">New Contact</h1>
<span class="input-label">Email</span>
<input type="text" placeholder="">
</label>
<button class="button button-block button-positive" ng-click="closeModal()">Create</button>
<button class="button button-block button-positive" ng-click="hideModal()">Hide Modal</button>
<button class="button button-block button-positive" ng-click="removeModal()">Remove Modal</button>
<button class="button button-block button-positive" ng-click="openActionSheet()">ActionSheet</button>
</div>
</div>
Expand Down Expand Up @@ -72,9 +72,6 @@ <h1 class="title">New Contact</h1>
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
$ionicModal.fromTemplateUrl('modal.html', function(modal) {
$scope.modal = modal;
}, {
Expand All @@ -85,9 +82,12 @@ <h1 class="title">New Contact</h1>
})

.controller('ModalCtrl', function($scope, $ionicActionSheet) {
$scope.close = function() {
$scope.hideModal = function() {
$scope.modal.hide();
}
};
$scope.removeModal = function() {
$scope.modal.remove();
};

$scope.openActionSheet = function() {
$ionicActionSheet.show({
Expand Down

0 comments on commit c4ca7a8

Please sign in to comment.