Skip to content

Instantly share code, notes, and snippets.

@jtushman
Created May 21, 2012 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtushman/2763609 to your computer and use it in GitHub Desktop.
Save jtushman/2763609 to your computer and use it in GitHub Desktop.
meteor snipit
// client/codepad.html
<template name="page">
{{#if any_page_selected}}
{{#with page}}
<h2>{{name}}</h2>
<textarea id="page_content" class="input-xlarge" style="width: 100%;">{{content}}</textarea>
<div class="form-actions">
<input type="button" class="btn btn-primary" value="Save" />
<button class="btn">Cancel</button>
</div>
{{/with}}
{{/if}}
</template>
// client/codepad.js
Template.page.page = function () {
var page_id = Session.get('page_id');
if (!page_id) return {};
console.log("tyring to find page:[" + page_id +"]")
var page = Pages.findOne(page_id);
return page || false;
}
Template.page.any_page_selected = function () {
return !Session.equals('page_id', null);
};
Template.page.events = {
'click input[type="button"]': function() {
var page_content = document.getElementById("page_content").value;
console.log("trying to update " + this._id + "with: [" + page_content + "]");
Pages.update(this._id, {$set: {content: page_content}});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment