I have absolutely no idea how to get this to work. I can create the models, but then I can’t run create or anything on them afterwards. I’ve been at this for 6 hours already… Please tell me where I’m going wrong :(!
1) Create a WorkflowCollection this.workflows = new WorkflowCollection(); workflows.length = 0.
2) Add empty workflows for each of the workflow ids (var workflow = [1,2,3]):
for(var i =0;i<workflow.length;i++;) {
this.workflows.add(new Workflow({fk_workflow_id: workflow[i]}));
}
3) workflows.length = 3. Render the views for the current workflows:
var self = this;
this.workflows.each(function(model) {
self.renderView(model.get("fk_workflow_id"), model);
});
renderView for example, calls a function:
if(this.kit) this.kit.close();
this.kit = new Workflow.PostageView({
model: model
// posView may change el? check later
});
4) Fetch the new data to update the view’s models. DOESN’T WORK.
this.workflows.fetch({
success: function () {
self.workflows.each(function (model) {
self.renderView(model.get("fk_workflow_id"), model);
});
}
});
5. Attempt to save a model:
FileApp.workflowRouter.pos.create is not a function
How come it can’t access create?! Full code: http://jsfiddle.net/8upZK/
Ugh. After 6 hours, it was because I should have been using the COLLECTION to create/update, rather than the view. I don’t know why I chose the view (step 5).
I.E. FileApp.workflowRouter.workflows.create(). Create/Add to a COLLECTION, not a view. Fuubar.