Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rerendering meteor.js on window resize?

Anybody figure out syntax to re-render a template on window resize, using Meteor.js? I tried doing a Meteor.flush(), but that doesn't seem to be the right approach.... :(

window.onresize = function(){
    Meteor.flush();
};  
like image 218
AbigailW Avatar asked Jan 06 '13 18:01

AbigailW


1 Answers

Change some session value when resizing the window, and then just have the template listen for that change:

<template name="body">
  {{touch}}
</template>

Template.body.touch = function() {
  return Session.get("touch");
}

Meteor.startup(function() {
  $(window).resize(function(evt) {
    Session.set("touch", new Date());
  });
});
like image 142
Rahul Avatar answered Oct 09 '22 01:10

Rahul