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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:41:00+00:00 2026-05-29T05:41:00+00:00

behold, a backbone view render call: render: function() { $(this.el).html(this.template({title: ‘test’})); //#1 this.renderScatterChart(); return

  • 0

behold, a backbone view render call:

render: function() {
  $(this.el).html(this.template({title: 'test'}));  //#1
  this.renderScatterChart();
  return this;
},

so, I call a standard render at #1. and then, i call a method [this time, it is a wrapper for charting lib] that looks for a div. the div is rendered by the render call. but at this point, it is not attached to the DOM yet (right?). so the chart call sadly dies.

what is the pattern for this? i’d love hear that there is a post-render callback. i’ve tried a few hacks around this, and sometimes i get the chart to work, but events don’t bind.

  • 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-05-29T05:41:00+00:00Added an answer on May 29, 2026 at 5:41 am

    My usual approach for this sort of thing is to use setTimeout with a timeout of zero to arrange for something to happen once the browser gets control again. Try this:

    render: function() {
        $(this.el).html(this.template({title: 'test'}));
    
        var _this = this;
        setTimeout(function() {
            _this.renderScatterChart();
        }, 0);
    
        return this;
    }
    

    Or, if renderScatterChart is already bound to the appropriate this:

    render: function() {
        $(this.el).html(this.template({title: 'test'}));
        setTimeout(this.renderScatterChart, 0);
        return this;
    }
    

    You can also use _.defer if you want to be more explicit about what you’re up to:

    defer _.defer(function, [*arguments])

    Defers invoking the function until the current call stack has cleared, similar to using setTimeout with a delay of 0.

    So you could also do it like this:

    // Assuming that `renderScatterChart` is bound to the appropriate `this`...
    render: function() {
        $(this.el).html(this.template({title: 'test'}));
        _(this.renderScatterChart).defer();
        return this;
    }
    
    // or if it isn't bound...
    render: function() {
        $(this.el).html(this.template({title: 'test'}));
    
        var _this = this;
        _(function() {
            _this.renderScatterChart();
        }).defer();
    
        return this;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this seems like a really simple Question...but behold :) Geek name:string Laser geek_id:integer, power:integer
Behold the C# code: IEnumerable<int> innerMethod(int parameter) { foreach(var i in Enumerable.Range(0, parameter)) {
Behold the following XAML: <Grid> <HyperlinkButton x:Name=Link Background=Green> <Grid Background=Red> <Grid.ColumnDefinitions> <ColumnDefinition Width=Auto />
This is a very simple, probably too simple question but I'm afraid my limited
This is a problem that is quite the opposite of the regular use of
I think this should be a rather simple thing to do, but I'm completely
Behold the code: using (var client = new WebClient()) { using (var stream =
Behold the code: using (var client = new WebClient()) { try { var bytesReceived
I finally finished my website and low and behold, there are some inconsistencies in
Behold the code: QImage *qi = new QImage(fullCharArray, imwidth, imheight, QImage::Format_Indexed8); ui->viewLabel->setPixmap(QPixmap::fromImage(qi,Qt::AutoColor)); Why does

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.