1

我在http://blog.sethladd.com/2013/09/forms-http-servers-and-polymer-with-dart.html阅读了 Seth Ladd 的博客

假设我添加了另一个 Form 组件 (Form2),重复步骤 3 和 4,然后在步骤 5 中导入 Form2。所以步骤 5 应该如下面的代码所示:

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    <title>Sample app</title>
    <link rel="stylesheet" href="parse_form_submit.css">
    <link rel="import" href="person_form.html">
    <script src="packages/polymer/boot.js"></script>
 </head>
 <body>
   <h1>Forms</h1>

<!-- Due to a bug in polymer, we can't use custom attributes.
     See https://code.google.com/p/dart/issues/detail?id=12262
     <person-form action="http://localhost:8888/submit"></person-form>
-->

<!-- in the meantime -->
    <person-form></person-form>
    <form-2><form-2>

  </body>
</html>

我现在应该将“提交”按钮放在其中一个表单中还是在导入表单的父级中?在任何一种情况下,单击提交按钮时如何通过 htnl5 获得自动验证等?对于在标签中包含自己的提交按钮的单个表单,一切正常,但当提交按钮放置在标签外部时,情况并非如此。

谢谢

4

1 回答 1

1

假设person-formform-2都是封装形式,每个都有自己的提交按钮。

我认为<form>标签不会进入 Shadow DOM 来查找自定义元素内的字段。所以最好把它想象成:

my-special-form extends form

也就是说,创建一个本身就是完全封装的表单的自定义元素。

于 2014-01-30T17:50:49.353 回答