To render views using the ViewManager, add a getTemplate
function to your view. Since the ViewManager
returns the jQuery AJAX deferred object, the views gets access to all the callbacks etc.
The WaitSpinnerView has a dependency on spin.js: http://fgnass.github.com/spin.js/
App.Views.CommentEditView = Backbone.View.extend({
tagName: "div",
className: "edit-comment",
events: {
},
initialize: function (options) {
_.bindAll(this, "render");
},
getTemplate: function () {
return App.ViewManager.getViewTemplate("/Comments/RenderEditView", { id: this.model.get("Id") });
},
render: function () {
var that = this;
this.$el.append(new App.Views.WaitSpinnerView().render().el);
this.getTemplate().done(function (response, status, jqxhr) {
that.$el.html(response);
});
return this;
}
});