我有一个铁形元素,我正在尝试将文件附加到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>