Skip to content

Instantly share code, notes, and snippets.

@jpmx
Created November 13, 2012 13:32
Show Gist options
  • Save jpmx/4065778 to your computer and use it in GitHub Desktop.
Save jpmx/4065778 to your computer and use it in GitHub Desktop.
Meteor preserve-inputs bug?
<head>
<title>bug-preserve-inputs</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
Radio Test: <input type="radio" name="myradio" {{isChecked}} /><br/><br/>
<button id="enableRadio">Enable Radio</button>
<button id="disableRadio">Disable Radio</button>
<pre>
Recreate:
+ Enable radio with button
+ Disable radio with button
= Reactivity stop working
</pre>
<hr/>
<a href="https://gist.github.com/4065778">Gist @ Github</a>
</template>
// Meteor 0.5.0
if (Meteor.isClient) {
Template.hello.events({
'click #enableRadio' : function () {
console.log("radio: true");
Session.set("radio", true);
},
'click #disableRadio' : function () {
console.log("radio: false");
Session.set("radio", false);
}
});
Template.hello.isChecked = function() {
return Session.get("radio") ? ' checked' : '';
}
}
@doubledare
Copy link

Just saw your question on IRC but you had gone. Not sure what is going on here. I also tried setting the Session variable from the browser console and it only works once. i.e.

Session.set("radio", true) -> Radio button is checked in webpage and source.
Session.set("radio", false) -> Radio button is unchecked in webpage and source.
Session.set("radio", true) -> Radio button is checked in source. No change in web page.

Very odd! It must be related to Reactive content but how I'm not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment