0
點擊一個button
我需要讓一個form
看起來有助於在單頁上添加內容。我做了一個form
和一個button
。如何讓表單出現在Meteor的點擊事件中?
<template name="addPost">
<button class="clickable">Add your dream</button>
<form>
{{#if clickable}}
<input type="text" name="title" class="title" placeholder="Title" required>
<textarea class="story" placeholder="What did you dream about tonight?"></textarea>
<input type="text" name="author" class="author" placeholder="Pen name" required>
<input type="submit" value="Publish">
{{/if}}
</form>
</template>
但我不知道如何從客戶端點擊事件回調到HTML,以使單擊按鈕後單擊窗體出現。
if (Meteor.isClient) {
Template.addPost.events({
'click .clickable': function() {
return;
});
};
一點題外話:如果你不要求的形式留在頁面刷新可見,避免使用會話變量,但只使用jquery解決這個問題。 – 2015-02-18 04:19:12
@SandervandenAkker是的也回答更新可以工作 – Ethaan 2015-02-18 04:27:22
謝謝Ethann和Sander,兩者都很好:) – mhlavacka 2015-02-18 07:05:29