Thursday, December 26, 2013

beforeActivate versus afterActivate in dojox views

OK, a beforeActivate method is run before the DOM is drawn and may be used to prep stuff to be drawn within the DOM. This is NOT the thing to use if you need to create something, for example a pie chart, reactively based upon the height of a div it is to sit within which may fluctuate with browser size, especially so if you are driving the height and width of the pie chart from JavaScript in lieu of CSS like this:

pieChart.surface.rawNode.setAttribute('width', domStyle.get(this.chartWrapper, "width"));
pieChart.surface.rawNode.setAttribute('height', domStyle.get(this.chartWrapper, "height"));

 
 

Instead, make use of the afterActivate method, which will allow you to blot on new stuff right after the rest of the DOM has appeared! Yay!

No comments:

Post a Comment