Some question about template

how can i get the element after rendered?
use track,autorun ??
i am confuse! pls help me if you know


What are you planing on doing in the onRendered function? In general, this should be the template context.

i want get the rendered element selector like the second result in console show

This depends on how your template(s) are structured. People always assume that Template.onRendered fires when all the HTML in your template is ready. If you have any reactivity in your template (iterating over a cursor, include sub template) then the template is rendered, but the HTML content is not ready when you think it is.

i add this in onRendered function

     Tracker.autorun  ->

          if FlowRouter.subsReady('debate')

               console.log $("#edit-content")

but it still console this, there is only this subscri


vistit the url path directly, it will get what i wanted.

but this page is redirect from other by use “FlowRouter.go” , then it not work correctly

In order for the code to run again you need to tell FlowRouter to watch path changes

As with all current route properties, these are not reactive, but can be combined with FlowRouter.watchPathChange() to get group names reactively.

check the docs

yes i have

  Tracker.autorun  ->

in both

That is too late. You need to specify it OUTSIDE of outorun.

unfortunately , i move it out of autorun or put it in Meteor.startup , all same

i put part of my code in the two templates

'click .fbtn-container': (e, instance) ->
	template = this"createDebate", null, null, null, new Array, false, (error, result)->
		if error?
			toastr.error t(error.message)
			if result?
				template.result = result
				createtimeout = Meteor.setTimeout -> 
					Meteor.clearTimeout createtimeout
					FlowRouter.go "debateedit", 
						slug: template.result

				toastr.error t("Debate_Create_Failed");

 Template.template2.onRendered ->

     Tracker.autorun  ->	
	if FlowRouter.subsReady('debate')
		console.log $("#edit-content")

In an event the instance is actually the template, so template = this is not what you want. Second, you might want to grab the slug in your autorun from FlowRouter, since it is now reactive and will trigger your autorun

Tracker.autorun ->
     var slug = FlowRouter.getParam("slug");

i don’t think it the flowrouter.watchPathChange(),

the blaze confuse me, i can’t get when the blaze render dom and data finished first time

blazehtml = Blaze.toHTML(Template.permissionsRole)
autoruntracker = Tracker.autorun (c)->
	console.log this # in tracker.autorun this is Window 
	console.log blazehtml #getView()# 
	if instance.subscriptionsReady() && $("#form-users").length > 0
		console.log this.$("#form-users")
		autoruntracker = undefined

so i use blaze.tohtml rerender get the dom html string, autorun monitor it to judge is blaze render dom and data finished first time