Don't need to do anything tricky any more.

Don't need to do 'constantOnceLoaded' as we can now just do
 - wait until loaded -- then constant.
This commit is contained in:
Tom Coleman 2012-10-18 13:40:11 +11:00
parent 2ee0028140
commit 9b9435333b
2 changed files with 3 additions and 24 deletions

View file

@ -1,7 +1,7 @@
<template name="post_edit">
{{#if canEdit "Posts" "replace"}}
<div class="grid submit">
{{#with post}}
{{#constant}}{{#with post}}
<form class="grid-block form-horizontal">
<div class="control-group">
<label class="control-label">Title</label>
@ -42,7 +42,7 @@
<input type="submit" value="Submit" />
</div>
</form>
{{/with}}
{{/with}}{{/constant}}
</div>
{{/if}}
</template>

View file

@ -7,28 +7,7 @@
Template.post_edit.helpers({
post: function(){
// The idea here is to isolate the call to findOne() so that it stops
// being reactive once data is found. The reason being that server scoring
// updates will 'change' the post, and meteor will overwrite the user's
// input, even if preserve is set.
// Kind of like {{#constant}}, except it waits for data.
//
// XXX: either figure out a different approach, or factor this out and
// use everywhere.
var outerContext = Meteor.deps.Context.current;
var innerContext = new Meteor.deps.Context;
var post;
innerContext.onInvalidate(function() {
// we don't need to send the invalidate through anymore if post is set
post || outerContext.invalidate();
});
innerContext.run(function() {
post = Posts.findOne(Session.get('selectedPostId'));
});
return post;
return Posts.findOne(Session.get('selectedPostId'));
},
categories: function(){
return Categories.find();