Question

My template shows different content based on a non-reactive value (in localStorage). I would like to do the following:

Template.foo.events
  'click #link': ->
    localStorage.setItem 'key', 'different'
    // re-render template foo

this.render() is undefined. Router.render('foo') does nothing.

Was it helpful?

Solution

The easiest way is to use a dependency tied to your value.

keyDep = new Deps.Dependency()

Template.foo.events
  'click #link': ->
    localStorage.setItem 'key', 'different'
    keyDep.changed()

Template.foo.key = ->
  keyDep.depend()
  return localStorage.getItem 'key'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top