At 22:30 of this video tutorial, https://www.youtube.com/watch?v=hBVYDVy3QNI, the author does something in coffeescript that I'm unable to translate to Javascript. He maintains the context of a custom region from within an inner callback using a fat arrow. As such, he is able to call close on the region from within a dialog close callback? How do I do that in Javascript?
Here is my custom region attempt but it fails on the call to this.closeDialog() because "this" refers to the dialog and not the region:
var DialogRegion = Backbone.Marionette.Region.extend({
onShow: function (view) {
this.$el.dialog({
modal: true,
resizable: false,
draggable: false,
width: "600px",
close: function (e, ui) {
this.closeDialog()//This doesn't work. Wrong context. Need outer DialogRegion context?
}
})
},
closeDialog: function () {
this.close();
this.$el.dialog("destroy");
}
});