0

I have an iron-form element and I'm trying to attach a file to the POST request. However, iron-form-presubmit never fires. I have the following function defined:

  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';
  });

But I never see 'restForm.addEventListener presubmit' on the console (Chrome dev tools), although I do see every other log, so I guess the function never gets called. When should the iron-form-presubmit event fire?

The form itself:

    <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>
lte__
  • 7,175
  • 25
  • 74
  • 131
  • I might be missing something pretty obvious here.. but to have the events from `iron-form` shouldn't you use the `iron-form` element instead of the HTML `form` element? – mishu May 10 '18 at 12:35
  • or maybe to have it wrap the `form` element, not instead of it, in fact.. as you can see in the docs: https://www.webcomponents.org/element/PolymerElements/iron-form – mishu May 10 '18 at 12:56

0 Answers0