Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
Move init to open.
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Ludlow committed Mar 9, 2016
1 parent 80dad77 commit 67847c4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ng2-bs3-modal/components/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ declare var jQuery: any;
</div>
`
})
export class ModalComponent implements AfterViewInit, OnDestroy {
export class ModalComponent implements OnDestroy {

id: string = uniqueId('modal_');
$modal: any;
Expand All @@ -28,16 +28,18 @@ export class ModalComponent implements AfterViewInit, OnDestroy {
@Input() size: string;
@Output() onClose: EventEmitter<string> = new EventEmitter();

ngAfterViewInit() {
init() {
this.$modal = jQuery('#' + this.id);
this.$modal.appendTo('body').modal({show: false});
this.$modal
.on('hide.bs.modal', (e) => {
.off('hide.bs.modal.ng2-bs3-modal')
.on('hide.bs.modal.ng2-bs3-modal', (e) => {
this.hiding = true;
if (this.result === ModalResult.None) this.dismiss();
this.result = ModalResult.None;
})
.on('hidden.bs.modal', (e) => {
.off('hidden.bs.modal.ng2-bs3-modal')
.on('hidden.bs.modal.ng2-bs3-modal', (e) => {
this.hiding = false;
this.overrideSize = null;
});
Expand All @@ -49,6 +51,7 @@ export class ModalComponent implements AfterViewInit, OnDestroy {
}

open(size?: string) {
this.init();
if (ModalSize.validSize(size)) this.overrideSize = size;
this.$modal.modal('show');
}
Expand Down

0 comments on commit 67847c4

Please sign in to comment.