我如何清除与HAML的形式

How do I clear a form with HAML?

本文关键字:HAML 清除 何清除      更新时间:2023-09-26

我有一个带有提交按钮的表单。下面是代码:

= form_for Comment.new(commentable: resource), url: polymorphic_path([resource, :comments]), remote: true, method: :post, data: { type: "text html" }, html: { rel: "nofocus", class: "new-comment" } do |f|
  .media
    = f.text_area :body, class: 'input-block-level resizable'
        %button.btn.btn-success(type="submit") Post Comment

是否有某种语法,HAML用于清除表单,或者有一个事件抛出,我可以使用js来清除表单?解决这个问题的最好方法是什么?

我不知道HTML,但是在HTML中你可以使用

<button type="reset">Click me</button>

<input type="reset" value="Click me" />

Ref .

  • https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button attr-type
  • https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input attr-type