0
2个问题:提交按钮输入文本区域相比为JS HTML
- 提交作品时,我打“输入”键盘上的。但是,提交按钮本身不起作用。
- 如果我希望将整个
<form>
更改为<textarea>
表单,我应该如何调整代码?我试图改变事件,但形式并不火。
事件JS
'submit form': function(e, template) {
e.preventDefault();
var $body = $(e.target).find('[name=body]');
var comment = {
body: $body.val(),
postId: template.data._id
};
var errors = {};
if (! comment.body) {
errors.body = "Input and/or attach content?";
return Session.set('commentSubmitErrors', errors);
}
Meteor.call('commentInsert', comment, function(error, commentId) {
if (error){
throwError(error.reason);
} else {
$body.val('');
}
});
的HTML
<div class="page-content message-content">
<form class="form-send-message" data-keyboard-attach >
<!-- <form> -->
<input name="body" id="body" type="text" placeholder="content">
<a href="#" class="button" type="submit">comment</a>
<!-- <a href="#" class="link" type="submit">
<i class="icon ion-android-send"></i>
picture icon doesnt work
</a> -->
<!-- what I aim to have
<textarea placeholder="add comment" name="body" id="body"></textarea>
<a href="#" class="link" type="submit">
<i class="icon ion-android-send"></i> -->
</form>
</div>
谢谢!愚蠢的疏忽对我而言 – Thinkerer