Git Product home page Git Product logo

iron-form's Introduction

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

iron-form's People

Contributors

andrewebdev avatar bicknellr avatar dfreedm avatar e111077 avatar fejesjoco avatar fredj avatar garlicnation avatar jab avatar jakemac53 avatar jklein24 avatar mcarey1590 avatar notwaldorf avatar patgmiller avatar radagi avatar rickymarcon avatar rictic avatar slavko-ptitsyn avatar taylorstine avatar tedium-bot avatar tjsavage avatar tmpduarte avatar tony19 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.