0

我有一个铁形元素,我正在尝试将文件附加到 POST 请求。但是,iron-form-presubmit从不开火。我定义了以下函数:

  restForm.addEventListener('iron-form-presubmit', function() {
    console.log('restForm.addEventListener presubmit')
    this.request.method = 'post';
    this.request.params = uploadComponentId.files[0];
    this.request.body = self.buildFormDataObject(this.request.body);
    restForm.querySelector('.output').innerHTML = 'Processing Request';
  });

但我从未'restForm.addEventListener presubmit'在控制台(Chrome 开发工具)上看到,尽管我确实看到了其他所有日志,所以我猜该函数永远不会被调用。事件应该在什么时候iron-form-presubmit触发?

表格本身:

    <form enctype="multipart/form-data" is="iron-form" method="post" action="http://localhost:7733/receivedoc" id="restForm" >
        <px-file-upload 
          id="uploadComponentId"
          message="Drag and drop files here, or click the button below." 
          multiple=false 
          accept=".xls,.xlsx">
        </px-file-upload>
        <button class="btn btn--large btn--icon" id="saveDataSetButton">
          <i class="fa-briefcase">Generate Pacing File</i>
        </button>
      </form>
4

0 回答 0