Created
May 21, 2012 18:00
-
-
Save jtushman/2763609 to your computer and use it in GitHub Desktop.
meteor snipit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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