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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:21:41+00:00 2026-06-15T15:21:41+00:00

backbone Model,board: define([ ‘underscore’, ‘backbone’, ‘collections/lists’, ‘iobind’, ‘iosync’ ], function( _, Backbone, Lists,ioBind,ioSync) {

  • 0

backbone Model,board:

 define([
  'underscore',
  'backbone',
  'collections/lists',
  'iobind',
  'iosync'
], function( _, Backbone, Lists,ioBind,ioSync) {

  var BoardModel = Backbone.Model.extend({
    urlRoot: 'board',
    noIoBind: false,
    socket: io.connect(''),
    idAttribute: '_id',

    defaults: {
      title: 'One Thousand and One Nights'
    },

    initialize: function() {
      this.id = 1;
      this.lists = new Lists;
      this.socket.emit('joinBoard',this.id);

      _.bindAll(this, 'getBoard');
      this.ioBind('initBoard', this.getBoard, this);
    },

    getBoard: function(data){
      this.set(data.data.board[0]);
    }
  });

  return BoardModel;
});

backbone View: boardView:

var IndexView = Backbone.View.extend({

    // Instead of generating a new element, bind to the existing elements in the HTML.
    el: '#board',

    // Board template html
    template: Mustache.render(Template.board),

    events: {

    },

    initialize: function() {
      //Init Data
      this.model = new Board();
//      var lists = {
//        lists: [
//          {name: "To Do",
//            cards:[
//              {name: "Art work for A."},
//              {name: "B Prototype."},
//              {name: "C prototype."}
//            ]
//          },
//          {name: "Doing",
//            cards: [
//              {name: "Art work for A."}
//            ]
//          },
//          {name: "Done"}
//        ]
//      }
//      var partial = {card: Template.card_in_list};
//      var listHtml = Mustache.render(Template.list,lists,partial);
//      template = $(this.template).find('.list-area').append(listHtml);
    },

    render: function() {

      console.log(this.model);
      console.log(this.model.toJSON());

      var partial = {card: Template.card_in_list};
      var listHtml = Mustache.render(Template.list,this.model,partial);
      template = $(this.template).find('.list-area').append(listHtml);
      this.$el.html(template);
    }

  });

in View function: render function, the console.log get different result.
console.log(this.model) can get correct object result:

child
_callbacks: Object
_changing: false
_escapedAttributes: Object
_ioEvents: Object
_pending: Object
_previousAttributes: Object
_silent: Object
attributes: Object
__v: 0
_id: "50b750a7795f285d4e000014"
created: "2012-11-29T12:10:15.269Z"
description: "simple is better, but not simpler"
dueDate: "2012-11-29T12:10:15.269Z"
lists: Array[6]
status: true
title: "test board unique"
__proto__: Object
changed: Object
cid: "c1"
getBoard: function () { [native code] }
id: "50b750a7795f285d4e000014"
lists: child
__proto__: ctor

but this.model.toJSON() only get model default values:

Object
title: "One Thousand and One Nights"
__proto__: Object

it confuse me. anyone know why reason the same model get different result.

  • 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-15T15:21:43+00:00Added an answer on June 15, 2026 at 3:21 pm

    I found i trigger boardView.render twice. when i change code:

    a = new boardView;
    a.render();
    

    to

    a = new boardView;
    

    i got the thing done.

    by the way thanks Marcel Falliere’s comments.

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

Sidebar

Related Questions

I have a backbone model like so define([ 'underscore', 'backbone' ],function( _,Backbone) { var
var JavascriptHelper = Backbone.Model.extend(JavascriptHelper, {}, // never initialized as an instance { myFn: function()
I have this model var Item = Backbone.Model.extend({ url: 'http://localhost/InterprisePOS/Product/loaditembycategory/Event Materials' }); var onSuccess
The code: var Appointment = Backbone.Model.extend({}); var appointment = new Appointment(); appointment.set('title', 'My knee
If i have this model: var myParentModel = Backbone.Model.extend({ defaults:{ parent1: null, parent2: null}
Imagine a Model/Collection like: var AModel = Backbone.Model.extend({ defaults: { a: 'a string', b:
I have created a model in backbone.js. var Content = Backbone.Model.extend({ // If you
//Model var Dog = Backbone.Model.extend({ name:'', breed:'' }); //Collection var Dogs = Backbone.Collection.extend({ model
This is the code: var MyModel = Backbone.Model.extend({ defaults: {std:, pod: } }); var
I have the following model: var User = Backbone.Model.extend({ defaults: { status: this.constructor.status.OFFLINE, },

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.