Created
July 1, 2014 14:36
-
-
Save ianmstew/6860511c3af9eab246de to your computer and use it in GitHub Desktop.
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
ContactManager.module("ContactsApp.Show", function(Show, ContactManager, Backbone, Marionette, $, _){ | |
var localCh = require('mymodule/mymodule.channel'); | |
Show.Controller = Marionette.Controller.extend({ | |
initialize: { | |
_.bindAll(this, 'contactEdited'); | |
this.listenTo(localCh, "contact:edit", this.contactEdited); | |
}, | |
contactEdited: function (contact) { | |
ContactManager.trigger("contact:edit", contact.get("id")); | |
}, | |
showContact: function(id){ | |
var loadingView = new ContactManager.Common.Views.Loading({ | |
title: "Artificial Loading Delay", | |
message: "Data loading is delayed to demonstrate using a loading view." | |
}); | |
ContactManager.mainRegion.show(loadingView); | |
var fetchingContact = ContactManager.request("contact:entity", id); | |
$.when(fetchingContact).done(function(contact){ | |
var contactView; | |
if(contact !== undefined){ | |
contactView = new Show.Contact({ | |
model: contact | |
}); | |
} | |
else{ | |
contactView = new Show.MissingContact(); | |
} | |
ContactManager.mainRegion.show(contactView); | |
}); | |
} | |
}); | |
}); |
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
ContactManager.module("ContactsApp.Show", function(Show, ContactManager, Backbone, Marionette, $, _){ | |
Show.Controller = { | |
showContact: function(id){ | |
var loadingView = new ContactManager.Common.Views.Loading({ | |
title: "Artificial Loading Delay", | |
message: "Data loading is delayed to demonstrate using a loading view." | |
}); | |
ContactManager.mainRegion.show(loadingView); | |
var fetchingContact = ContactManager.request("contact:entity", id); | |
$.when(fetchingContact).done(function(contact){ | |
var contactView; | |
if(contact !== undefined){ | |
contactView = new Show.Contact({ | |
model: contact | |
}); | |
contactView.on("contact:edit", function(contact){ | |
ContactManager.trigger("contact:edit", contact.get("id")); | |
}); | |
} | |
else{ | |
contactView = new Show.MissingContact(); | |
} | |
ContactManager.mainRegion.show(contactView); | |
}); | |
} | |
} | |
}); |
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
ContactManager.module("ContactsApp.Show", function(Show, ContactManager, Backbone, Marionette, $, _){ | |
var localCh = require('mymodule/mymodule.channel'); | |
Show.MissingContact = Marionette.ItemView.extend({ | |
template: "#missing-contact-view" | |
}); | |
Show.Contact = Marionette.ItemView.extend({ | |
template: "#contact-view", | |
events: { | |
"click a.js-edit": "editClicked" | |
}, | |
editClicked: function(e){ | |
e.preventDefault(); | |
localCh.trigger("contact:edit", this.model); | |
} | |
}); | |
}); |
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
ContactManager.module("ContactsApp.Show", function(Show, ContactManager, Backbone, Marionette, $, _){ | |
Show.MissingContact = Marionette.ItemView.extend({ | |
template: "#missing-contact-view" | |
}); | |
Show.Contact = Marionette.ItemView.extend({ | |
template: "#contact-view", | |
events: { | |
"click a.js-edit": "editClicked" | |
}, | |
editClicked: function(e){ | |
e.preventDefault(); | |
this.trigger("contact:edit", this.model); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment