I am currently writing a blog, and i want a preview window when adding a new article. So i have a autoform, where you can enter the new Article:
<template name = "AddArticle">
<div class = "content-container">
<div class = "content-wrapper">
<h2>Add new Article</h2>
<!--{{> quickForm id="insertArticleForm" type = "insert"}}-->
{{#autoForm collection="BlogPosts" id="insertArticleForm" type="insert" class = "content-form"}}
<fieldset>
{{> afQuickField name="author"}}
{{> afQuickField name="title"}}
{{> afQuickField name="description"}}
{{> afQuickField name="content" rows=15 id = "content-textarea"}}
<button type="submit" class="btn btn-primary">Insert</button>
</fieldset>
{{/autoForm}}
</div>
</div>
{{> Preview}}
And I have this preview window
<template name = "Preview">
<div class = "content-container preview">
{{>SlideBlock title = 'Preview <button class ="btn btn-default pull-right">Refresh</button>' content = "PreviewContent"}}
</div>
<template name = "PreviewContent">
<div id = "preview-content" class = "content-wrapper">
<span>{{{content}}}</span>
</div>
And this Helper function which is supposed to copy the text from the textarea into the preview window
Template.PreviewContent.helpers({
content: function(){
var content = $("#content-textarea");
console.log(content);
return content;
}
});
The problem is, that the current output ist just [object Object]. I believe it may be, that the helper function is performed, when the dom isnt ready yet, but I am not 100% sure.
Edit:
Oh forgot to add it again after trying stuff out. The output with .html() / .val() / .text() all just return undefined.