Last active
August 29, 2015 14:01
-
-
Save ajaxray/b245509903f107d8a47f to your computer and use it in GitHub Desktop.
My version of Dialog/Modal/Popup region for Backbone.Marionette using Bootstrap modal
This file contains 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
define([ | |
'app', | |
'marionette' | |
], function(app, Marionette){ | |
return Marionette.Region.extend({ | |
onShow: function(view){ | |
this.listenTo(view, "dialog:close", this.closeDialog); | |
var self = this; | |
this.$el.modal({ | |
backdrop: true, | |
keyboard: true, | |
show: true | |
}); | |
}, | |
closeDialog: function(){ | |
this.stopListening(); | |
this.close(); | |
this.$el.modal('hide'); | |
} | |
}); | |
}); |
This file contains 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
define([ | |
'marionette' | |
], function (Marionette) { | |
'use strict'; | |
return Marionette.ItemView.extend({ | |
template: 'modal_content_with_close_btn', | |
events: { | |
'click .close': function(e) { | |
e.preventDefault(); | |
this.trigger('dialog:close'); | |
} | |
} | |
}); | |
}); |
This file contains 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
<div class="modal-dialog"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | |
<h4 class="modal-title"><i class="fa fa-life-ring"></i> Help</h4> | |
</div> | |
<div class="modal-body"> | |
This is help text html. | |
</div> | |
</div><!-- /.modal-content --> | |
</div><!-- /.modal-dialog --> |
This file contains 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
<!-- | |
Your layout html should contain the following html. | |
Then you have to use #dialog as the region element. For example - | |
app.addRegions({ | |
main: '#main', | |
dialog: { | |
selector: "#dialog", | |
regionType: DialogRegion | |
} | |
}); | |
--> | |
<div class="modal fade" id="dialog" tabindex="-1" role="dialog" aria-hidden="true"> | |
</div><!-- /.modal --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment