2016-03-05 55 views
0

2个问题:提交按钮输入文本区域相比为JS HTML

  1. 提交作品时,我打“输入”键盘上的。但是,提交按钮本身不起作用。
  2. 如果我希望将整个<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> 

回答

0

<a>标签没有一个类型的属性 - 你可以把一个<input type="submit">和风格如何,你像或者在标签上放一个点击监听器,但最好的做法是b e前

+0

谢谢!愚蠢的疏忽对我而言 – Thinkerer