Domanda

I'm trying to draw a timeline when the timeline route is opened. Currently have and it partially works, i.e. if you refresh the timeline page, but navigating to timeline page will not draw timeline. I was wondering if it is possible to do {{partial onload="drawTimeline}} or something along those lines.

I've also tried making a handlebars helper {{drawTimeline}} and calling that when partial is loaded, but it is getting an undefined value.

EDIT: kingpin2k's fix worked for me. This is what I did:

HTML:

{{#view Blocks.Timeline}}
  <div id="mytimeline"></div>
{{/view}}

JS:

Blocks.Timeline = Em.View.extend({
didInsertElement : function(){
   drawVisualization();
}
});
È stato utile?

Soluzione

Is drawTimeline a function on the controller of the current route?

If so, create an associated view and hook up to the didInsertElement and run the function there.

App.SomethingView = Em.View.extend({
  didInsertElement : function(){
   // do it here
  }
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top