Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7968551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:05:43+00:00 2026-06-04T07:05:43+00:00

I have a backbone setup for Workflows. There are multiple workflows/models visible on the

  • 0

I have a backbone setup for Workflows. There are multiple workflows/models visible on the page at any given time. If a workflow is not started yet (i.e. not in the database), it is displayed as a New model. Having trouble with passing the fetched model to the view. I’m only passing the attributes rather than the collection it seems? Anyone have any ideas?

When I fetch all workflows from the database, it returns a JSON array of workflows progress.

[{
        "ref_id": 41959,
        "parent_ref_id": 35,
        "fk_workflow_id": 2,
        "stage": 1,
        "status_max": 4,
        "updated": "2012-05-14 17:30:46"
}, {
        "ref_id": 41960,
        "parent_ref_id": 35,
        "fk_workflow_id": 3,
        "stage": 3,
        "status_max": 4,
        "updated": "2012-05-14 12:30:48"
}]

When the page is loaded, all workflows are created as “new models”, because we don’t know if they’ve been started yet. Once the fetch has returned the models that have been started, I have to pass the appropriate model to the view. I’m having trouble figuring out how to pass the model properly (i.e. I can pass the attributes, but it seems after that, I don’t have access to the collection.create functions etc?)

    var self = this;
    this.workflows = new Workflow.WorkflowCollection();
    this.workflows.fetch({
        data:{
            ref_id: REF_ID
        },
        success: function(model, response) {
            for(var i = 0, ln = model.models.length; i< ln;i++) {
            self.switchWorkflow(model.models[i].get("fk_workflow_id"), new Workflow(model.models[i].attributes));
                }
            }
        });

This is the only way I can figure backbone knows how many models it needs to setup (short of initiating each of the workflows for each customer – ~1million rows)

setupWorkflowSpaces: function(model) {

    for(var i =0; i<Workflow.FileWorkflows.length;i++) {
        this.switchWorkflow(Workflow.FileWorkflows[i], false);
    }
},
switchWorkflow: function(workflow_id, model) {
    if(!model)
        model = new Workflow;
    switch(workflow_id) {
        case 1:
            this.applicationProcessView(model);
            break;
        case 2:
            this.kitView(model);
            break;
        case 3:
            this.posView(model);
            break;
        default:
            alert('wut');
            break;
    }
},

kitView: function(model) {
    console.log(model);
    model.set("fk_workflow_id", 2);
    if(this.kit) this.kit.close();
    this.kit = new Workflow.PostageView({
        model: model
    });
},
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:05:44+00:00Added an answer on June 4, 2026 at 7:05 am

    Try defining the model property in your Backbone Collection:

    var Workflow.WorkflowCollection = Backbone.Collection.extend({
      model: Workflow
    });
    

    If defined, the raw attributes coming back from your server will be converted into a Workflow model.

    Then you won’t have to iterate through the collection that is returned via the success callback in fetch. All the added models will be in your collection and you can use the .create() method to continue adding more.

    After fetch you can iterate through the updated collection using WorflowCollection.each. In the loop you can run your switch statement to assign the each model to an appropriate view.

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two backbone models, loaded from server: var Model = Backbone.Model.extend({}); var SubModel
We are using Backbone.js to build client-side UI that manipulates models shared by multiple
I'm having a heckuva time understanding the documentation for Backbone-Relational ; it's not 100%
Is it possible to have backbone.js's routing feature determine multiple actions? for example, my
Is there a way to have a different Backbone.sync method invoked for a subset
I have a backbone.js collection with male and female models. In my interface I
I'm trying to add an event to my backbone view I have setup. I
I'm using Backbone with Rails (3.1). I have a search page. The first search
I'm having a hard time figuring out why this is not working. I have
I have Backbone.js collection that holds (for example) 30 items. I want to pass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.