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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:56:27+00:00 2026-06-12T06:56:27+00:00

I would like to fetch model from specific url with parameter: url: server/somecontroller/id/?type=gift Simple

  • 0

I would like to fetch model from specific url with parameter:
url: server/somecontroller/id/?type=gift

Simple working way is:

collection.fetch({ data: { type: 'gift'} });

But I want to set it in model:

    ...
    if(id){
      App.coupon = new AffiliatesApp.Coupon({id: id});
    } else {
      App.coupon = new AffiliatesApp.Coupon({id: 'somecontroller'}, {type: 'gift'});
    }
    App.coupon.fetch();

How can I achieve it?

  • 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-12T06:56:29+00:00Added an answer on June 12, 2026 at 6:56 am

    The easiest way to achieve this is to override Backbone’s url method on the Coupon model with one defined by you. For example you can do :

    Affiliates.Coupon = Backbone.Model.extend({
      urlRoot : "server/somecontroller/",
      url : function(){
        var url = this.urlRoot + this.id;
        if(this.get("type")){
          url = url + "/?type=" + this.get("type");
        }
        return url;
      }
    });
    

    This solution is easy to implement but has a drawback: the generated URL will be used for every action that syncs to the server (fetch,save,..).

    If you need to have a finer control over the generation of the URL depending on what action you are doing you will need to override Backbone’s Sync method for your model.

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

Sidebar

Related Questions

I would like to fetch the result set from a function for each row
My Flash movie would like communicate with MySQL server to fetch and save data
When fetching content from a database using activerecord, I would like to fetch a
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode
Would like to know the c# code to actually retrieve the IP type: Static
I would love to call a controller action from within a model. Yes, MVC.
Problem: I would like to download 100 files in parallel from AWS S3 using
I would like to render a view for a model when the model is
I have a model, below, and I would like to get all the distinct
Is there an easy way to fetch the ManyToMany objects from a query that

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.