Last active
August 29, 2015 14:19
-
-
Save Akii/27624ef45ce20081e62d to your computer and use it in GitHub Desktop.
Really simple ember modal implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
modal: undefined, | |
show: false, | |
setupModal: function() { | |
var modal = this.$('.modal').modal({ | |
show: this.get('show'), | |
backdrop: false | |
}); | |
this.$('.modal-backdrop').click(function() { | |
modal.modal('hide'); | |
}); | |
modal.on('hide.bs.modal', function() { | |
var show = this.get('show'); | |
if (show === false) { | |
return true; | |
} | |
this.sendAction('hide'); | |
return false; | |
}.bind(this)); | |
modal.on('hidden.bs.modal', function() { | |
this.sendAction('hidden'); | |
}.bind(this)); | |
this.set('modal', modal); | |
}.on('didInsertElement'), | |
onVisibilityChanged: function() { | |
var dialog = this.get('modal'), | |
show = this.get('show'); | |
if (show === true) { | |
dialog.modal('show'); | |
} else { | |
dialog.modal('hide'); | |
} | |
}.observes('show') | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Mixin.create({ | |
showModal: true, | |
resetDialog: function() { | |
this.setProperties({ | |
'showModal': true | |
}); | |
}, | |
actions: { | |
hideModal: function() { | |
this.set('showModal', false); | |
}, | |
showModal: function() { | |
this.set('showModal', true); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment