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

  • Home
  • SEARCH
  • 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 8428081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:57:23+00:00 2026-06-10T04:57:23+00:00

Trying to create a backbone plugin that inherits from Backbone.Model but overrides the sync

  • 0

Trying to create a backbone “plugin” that “inherits” from Backbone.Model but overrides the sync method.

This is what I have so far:

Backbone.New_Plugin = {};
Backbone.New_Plugin.Model = Object.create(Backbone.Model);
Backbone.New_Plugin.Model.sync = function(method, model, options){
    alert('Body of sync method');
}

The method: Object.create() was taken directly from the book Javascript: The Good Parts:

Object.create = function(o){
    var F = function(){};
    F.prototype = o;
    return new F();
};

I’m getting an error when trying to use the new model:

var NewModel = Backbone.New_Plugin.Model.extend({});
// Error occurs inside backbone when this line is executed attempting to create a
//   'Model' instance using the new plugin:
var newModelInstance = new NewModel({_pk: 'primary_key'}); 

The error occurs on line 1392 of the development version of Backbone 0.9.2. inside the function inherits():

    Uncaught TypeError: Function.prototype.toString is not generic .

I am trying to create a new Plugin in the way that the backbone library Marionette creates new versions of Views. IT looks like I am misunderstanding the way that this should be done.

What is a good way to create a new plugin for backbone?

  • 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-10T04:57:24+00:00Added an answer on June 10, 2026 at 4:57 am

    The way you’re extending Backbone.Model is not how you want to go about it. If you want to create a new type of model, just use extend:

    Backbone.New_Plugin.Model = Backbone.Model.extend({
        sync: function(method, model, options){
            alert('Body of sync method');
        }
    });
    
    var newModel = Backbone.New_Plugin.Model.extend({
        // custom properties here
    });
    
    var newModelInstance = new newModel({_pk: 'primary_key'});
    

    On another note, Crockford’s Object.create polyfill is considered outdated because (I believe) more recent implementations of Object.create take more than one argument. Also, the particular function you’re using does not defer to a native Object.create function, should it exist, although, you may have just omitted the if (typeof Object.create !== 'function') statement that should wrap that function.

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

Sidebar

Related Questions

I am trying to create a backbone.js model with dynamic keys but can't seem
I am trying around with Backbone.js and get along so far, but I have
I'm starting out with backbone and I'm trying to create a simple view that
Basically, I'm trying to do something like this: Person = Backbone.Model.extend({ validate: { ...
I am trying to create a Task application with Backbone.Js. Task is a model
I'm trying to make a quick sample Backbone.js app that has a Post model,
I'm trying to set up my first Backbone Model that implements RESTful WCF services.
I'm trying to create a basic version of this example in CoffeeScript: http://davidsulc.com/blog/2012/04/15/a-simple-backbone-marionette-tutorial/ .
I'm trying to create a model in a Rails 3.1rc4 application that is not
I am trying to use the Pagination plugin for backbone.js to create an infinite

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.