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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:31:15+00:00 2026-06-12T01:31:15+00:00

I am developing a Backbone web application and I want to know that how

  • 0

I am developing a Backbone web application and I want to know that how can post data from the view
This is my Model:

App.Models.edit = Backbone.Model.extend({
    defaults : {
        id    : undefined,
        fname : undefined,
        lname : undefined,
        phone : undefined,
        address : undefined,
        email : undefined,
        url: undefined,
    },

    initialize: function(){
        this.set({url : '../api/getOne/' + App.CurrentID });
    },

    getAttrs: function(attr){
        return this.get(attr);
    }
    });

And this is my view:

App.Views.edit = Backbone.View.extend({
    el: $("#modal"),

    initialize: function(){
        App.TplNames.edit = $('body');
        App.Tpls.edit('edit');
        this.model.bind("reset", this.render, this);
        this.render();
    },

    events: {
        'click .btnSave': 'saveDetails',
    },

    saveDetails: function(){
        this.model.save();
        //console.log(this.model);
    },

    render: function(){
        var elem = '';
        $.each(this.model.models, function(i, k){
        var template = _.template( $('#tpl_edit').html(), k.toJSON() );
        elem += template;
        });
        $(this.el).html(elem);
        $("#myModal").modal('show');
        $("#myModal").on('hidden', function(){
        //alert(123);
        document.location.href = App.Url + '#view';
        });
        var attrs = "";
        $.each(this.model.models, function(i, k){
        attrs = k.toJSON();
        });
        $("#fname").val(attrs.fname);
        $("#lname").val(attrs.lname);
        $("#Email").val(attrs.email);
        $("#Phone").val(attrs.phone);
        $("#Address").val(attrs.address);
        //console.log(attrs);
    }
    });

And it is my Router

App.Router = Backbone.Router.extend({
    routes: {
        ""      :   "def",
        "home"  :   "def",
        "view"  :   "getAll",
        "edit/:id"  :   "edit",
        "add"   :   "addContact",
    },

    def: function(){
        this.mainModel = new App.Collections.Main();
        this.mainView  = new App.Views.Main({model: this.mainModel});
        //this.mainModel.fetch();
    },

    edit: function(id){
        App.CurrentID = id;
        var contactCollObj = new App.Collections.edit();
        viewObj = new App.Views.edit({model: contactCollObj});
        contactCollObj.fetch();
        viewObj.render();
        //console.log(contactCollObj);
    },

    getAll: function(){
        //alert(123);
        var collObj = new App.Collections.View();
        var viewObj = new App.Views.View({model: collObj});
        collObj.fetch();
    },

    addContact: function(){
        //var model = new App.Collections.AddContact();
        model = new App.Models.AddContact();
        var view = new App.Views.AddContact({model: model});
        //view.render();
    }


    });

var app = new App.Router();
Backbone.history.start();

And when I want to save the model, It generates an error:

this.model.save is not a function

Every thing is okay except the above…

  • 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-12T01:31:17+00:00Added an answer on June 12, 2026 at 1:31 am

    In your router you pass collection to App.Collections.edit view as model:

    var contactCollObj = new App.Collections.edit();
    viewObj = new App.Views.edit({model: contactCollObj});
    

    That is why you cannot call save(). save() is only available for a model not a collection.

    You probably want to initialize view with collection

    viewObj = new App.Views.edit({collection: contactCollObj});
    

    And then also modify some of your view code accordingly.

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

Sidebar

Related Questions

Developing a web application that I've registered with Twitter. In this app, I might
Developing an application for Android, i want to record data that will be usefull
Developing a Sencha Touch MVC app that pulls data from json store (thats set
I'm developing application using backbone.js & jquery. I have following code in model: runReport:
A Backbone app which I'm developing has a collection and a model, and associated
Iam developing one application.In that iam placing the radio buttons(uiimageview) on table view and
I'm currently developing a new web application. This is the first time I'm using
I'm developing backbone app, which makes crossdomain restful request. The nested data structure in
Developing an app that people pay a monthly subscription to use. They can pay
Developing an app that uses data synchronization. Sending images (even resized) takes time if

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.