Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My usual approach for this sort of thing is to use <a href="https://developer.mozilla.org/en-US/docs/Web/API/window.setTimeout" rel="noreferrer"><code>setTimeout</code></a> with a timeout of zero to arrange for something to happen once the browser gets control again. Try this:</p> <pre><code>render: function() { $(this.el).html(this.template({title: 'test'})); var _this = this; setTimeout(function() { _this.renderScatterChart(); }, 0); return this; } </code></pre> <p>Or, if <code>renderScatterChart</code> is already bound to the appropriate <code>this</code>:</p> <pre><code>render: function() { $(this.el).html(this.template({title: 'test'})); setTimeout(this.renderScatterChart, 0); return this; } </code></pre> <p>You can also use <a href="http://underscorejs.org/#defer" rel="noreferrer"><code>_.defer</code></a> if you want to be more explicit about what you're up to:</p> <blockquote> <p><strong>defer</strong> <code>_.defer(function, [*arguments])</code></p> <p>Defers invoking the <strong>function</strong> until the current call stack has cleared, similar to using <strong>setTimeout</strong> with a delay of 0.</p> </blockquote> <p>So you could also do it like this:</p> <pre><code>// 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; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload