New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@mstyk/iron-form

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mstyk/iron-form

Makes it easier to manage forms

latest
Source
npmnpm
Version
1.0.16
Version published
Maintainers
1
Created
Source

Build status

Demo and API docs

##<iron-form>

<iron-form> is an HTML <form> element that can validate and submit any custom elements that implement Polymer.IronFormElementBehavior, as well as any native HTML elements. For more information on which attributes are available on the native form element, see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form

It supports both get and post methods, and uses an iron-ajax element to submit the form data to the action URL.

Example:

<form is="iron-form" id="form" method="post" action="/form/handler">
  <paper-input name="name" label="name"></paper-input>
  <input name="address">
  ...
</form>

By default, a native <button> element will submit this form. However, if you want to submit it from a custom element's click handler, you need to explicitly call the form's submit method.

Example:

<paper-button raised onclick="submitForm()">Submit</paper-button>

function submitForm() {
  document.getElementById('form').submit();
}

To customize the request sent to the server, you can listen to the iron-form-presubmit event, and modify the form'siron-ajax object. However, If you want to not use iron-ajax at all, you can cancel the event and do your own custom submission:

Example of modifying the request, but still using the build-in form submission:

form.addEventListener('iron-form-presubmit', function() {
  this.request.method = 'put';
  this.request.params = someCustomParams;
});

Example of bypassing the build-in form submission:

form.addEventListener('iron-form-presubmit', function(event) {
  event.preventDefault();
  var firebase = new Firebase(form.getAttribute('action'));
  firebase.set(form.serialize());
});

Keywords

web-components

FAQs

Package last updated on 15 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts