I'm wondering if it is possible to access variable / method of a template in iron:router.
My problem is : I want to reset a lot of stuff launched by my template (timer / subscription / whatever) on the page unload (from a change page menu)
But the window.onBeforeUnload is only triggered when we are changing the url. But my Iron:router is not reffreshing page and the only way i found to get this unload event is passing by iron:router's unload event. But there, I just can't access to my template variable or method. So the only way i found at the moment is passing my reset var by session... And i find this very awful !
Router.route('/printList', {
name: 'printjoblistList',
unload: function () {
var reset = Session.get("sessionTestIronRouter");
}
Have you got advice, tips and bests ways to do that ? :)
答案 0 :(得分:0)
好的,解决了这个问题,虽然不是很干净。
我在模板客户端大小中声明了一个globalHelper:
Router.route('/template', {
name: 'myTemplate',
unload: function (e, obj) {
Blaze._globalHelpers.functionToCall();
}
});
在我的卸货铁路上:
debugger;