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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:43:55+00:00 2026-06-02T10:43:55+00:00

Is it possible to create model and view in Backbone.js with parameters ? I

  • 0

Is it possible to create model and view in Backbone.js with parameters ?
I try simple like

    var TestModel = Backbone.Model.extend( {
        initialize: function(test){
        this.set('test',test);
        alert("test");
    }
});

but I got message this.set is not a function.

  • 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-02T10:43:56+00:00Added an answer on June 2, 2026 at 10:43 am

    There’s a syntax error in your example code, but that should work just fine. You also need to account for the model’s attributes as the first parameter and reference a generic options object as the second parameter (see the code here http://backbonejs.org/docs/backbone.html#section-28 )

    From your sample code, though, it looks like you’re just trying to pass data to the model, which is handled for you automatically.

    
    var TestModel = Backbone.Model.extend({});
    
    var t = new TestModel({foo: "bar"});
    
    console.log(t.get("foo"));
    

    Or if you’re trying to get some options, you can do this:

    
    var TestModel = Backbone.Model.extend({
      initialize: function(attrs, options){
        console.log(options.foo);
      }
    });
    
    var t = new TestModel(null, {
      foo: "bar"
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using EF, is it possible to create the model from a disconnected dataset? Keep
Is it possible to create a SQL DB from a Linq2Sql model? I managed
Hi it'd like to know if it's at all possible create a parametric equalizer
Is it possible to create a custom route for GDirections to walk around? Like
From my controller I set my Model and view like: ModelAndView mav = new
I am using C# to create a view model that I later serialize into
Let's say I have a PHP Model-View-Controller framework that maps an address like http://example.com/admin/posts/edit/5
Can anyone explain why it's not possible to create your own view controller hierarchies
Is it possible to create one model that stands for two different objects? for
I was wondering if it is possible to create a template for a view

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.