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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:00:20+00:00 2026-06-13T06:00:20+00:00

I have an issue to access my collection on a view’s method, in fact,

  • 0

I have an issue to access my collection on a view’s method, in fact, it works well from the initialize() method, but i created another one (drawVisualization()), and i get an undefined error when i try to access this.collection, it’s probably a stupid question but i didn’t find any solution, i tried to use _.bind on the initialize method but doesn’t seem works in this case, here is the code:

App.Views.account = Backbone.View.extend({

className: 'account',

el: $('#account-container'),

initialize: function(){
    console.log(this.collection.toJSON()); //Works fine !
    this.template = _.template($('#account-template').html());
    _.bind(this.drawVisualization, this); //Seems to be useless
},

render: function(){
//Some code...
    return this;
},

drawVisualization: function(){
      console.log(this.collection.toJSON()); //Fail because of undefined collection !
}

Thanks for your help !

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

    I don’t have an idea why it doesn’t work, but try using underscore’s bindAll.

    initialize: function(){
      _.bindAll(this);  
      this.template = _.template($('#account-template').html());
    } 
    

    For me just dumping bindAll in the beginning of each view initialize is a good way of avoiding this kind of problems.

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

Sidebar

Related Questions

The Issue: when multiple users have access to the same working directory, permissions issues
I have an issue of alphabetically sorting the contacts picked from the address book
I have an issue while getting the file name with out extension from a
I am facing this issue: I have lots of threads (1024) who access one
i have a quite classical issus : Access Lazy Collection outside of the DAO,
So, I once again seem to have an issue with MS Access being finicky,
I have 2 threaded methods running in 2 separate places but sharing access at
I currently have an issue when updating a component collection on an entity. It
I have issue with: <form:checkboxes path=roles cssClass=checkbox items=${roleSelections} /> If previous line is used
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So

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.