Created
December 1, 2015 16:32
-
-
Save mxriverlynn/8bae02c064407d64759f to your computer and use it in GitHub Desktop.
backbone / marionette / bootstrap: modal dialog example for "Confirm Delete" dialog
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 ConfirmDelete from "./confirmDelete" | |
import ConfirmDeleteViewfrom "./confirmDeleteView" | |
var confirmView = new ConfirmDeleteView({ | |
model: myModel | |
}); | |
ConfirmDelete.confirm(confirmView, () => { | |
// delete was confirmed... do something, here | |
}); |
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 ConfirmLayout from "./confirmDeleteLayout"; | |
var ConfirmDelete = { | |
configure: function(options){ | |
this.region = options.region; | |
}, | |
confirm: function(view, cb){ | |
var $el = $("#modal-window"); | |
var layout = new ConfirmLayout(); | |
layout.on("render", () => { | |
layout.bodyRegion.show(view); | |
}); | |
layout.on("cancel", () => { | |
$el.modal("hide"); | |
}); | |
layout.on("confirm", () => { | |
$el.modal("hide"); | |
cb(); | |
}); | |
this.region.show(layout); | |
$el.modal(); | |
} | |
}; | |
export default ConfirmDelete; |
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
var ConfirmDeleteLayout = Marionette.LayoutView.extend({ | |
template: "#confirm-delete-layout-template", | |
className: "modal-content", | |
regions: { | |
bodyRegion: ".modal-body" | |
}, | |
events: { | |
"click .cancel": "cancelClicked", | |
"click .confirm": "confirmClicked" | |
}, | |
cancelClicked: function(e){ | |
e.preventDefault(); | |
this.trigger("cancel"); | |
}, | |
confirmClicked: function(e){ | |
e.preventDefault(); | |
this.trigger("confirm"); | |
} | |
}); | |
export default ConfirmDeleteLayout; |
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
var ConfirmDeleteView = Marionette.ItemView.extend({ | |
template: "#confirm-delete-effective-dates-template" | |
}); | |
export default ConfirmDeleteView; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment