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 7756743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:54:05+00:00 2026-06-01T12:54:05+00:00

I have an API that filters a set of objects based on the ID

  • 0

I have an API that filters a set of objects based on the ID present in the URL, like so:

http://localhost:8000/api/v1/goal_update/?goal__id=12&format=json

I have a collection that does a GET request on the above URL. Here is the code for the collection:

  var GoalUpdateList = Backbone.Collection.extend({

    // Reference the Goal Update model
    model: GoalUpdate,

    // Do HTTP requests on this endpoint
    url: function() {
      return "http://localhost:8000/api/v1/goal_update/?goal__id=" + this.goal_id + "&format=json";
    },

    // Set the goal ID that the goal update list corresponds to
    initialize: function(goal_id) {
      this.goal_id = goal_id;
    },

  });

I want to pass in the ID when I create a new instance of the collection, so I created a view that has this code:

this.collection = new GoalUpdateList(this.model.get("id"));

It thinks that I am passing in model parameters, though. I am trying to pass in information that tells the collection what URL to use. So it runs the ID through a validate function and messes up the rest of the backbone code.

  • 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-01T12:54:07+00:00Added an answer on June 1, 2026 at 12:54 pm

    Backbone’s collections expect model data as the first parameter, as you’ve already noted. But you can specify a second parameter as an object literal, like other Backbone objects. Just pass null or undefined as the first parameter, and then in your collection initialize method, get the options as the second parameter.

    
    GoalUpdateList = Backbone.Collection.extend({
    
      initialize: function(data, options){
        this.goal_id = options.goal_id;
      }
    
    });
    
    new GoalUpdateList(null, model.get("goal_id"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an API that can be implemented by various vendors. I can send
I have an API that returns a promise from a deferred object. The problem
I'm developing a REST api. To simplify my question, I have an API that
I have an Jersey API that returns Odata standard responses and consumes the same.
I have an API call that returns a byte array. I currently stream the
I have a api app that sits behind a few client facing apps. The
I currently have a REST API that must be authenticated via BasicAuth, but later
I have built an API framework that includes a lot of communication-related options, including
I have an open-source iPhone API that I downloaded, and that is a standalone
I'm using django-piston for my REST json api, and I have it all set

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.