calling javascript on rendering views in BackBone js. post-render callback?

后端 未结 8 1657
粉色の甜心
粉色の甜心 2020-12-04 19:55

behold, a backbone view render call:

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


        
8条回答
  •  无人及你
    2020-12-04 20:40

    I know this is answered, but thought I would share. Underscore js has this covered for you with the _.defer function.

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

    According the the Underscore docs, this is effectively the same thing as the accepted solution.

提交回复
热议问题