All Projects → rnicholus → Ajax Form

rnicholus / Ajax Form

Licence: mit
HTML forms on performance-enhancing drugs

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ajax Form

Clipboard Copy Element
Copy element text content or input values to the clipboard.
Stars: ✭ 198 (-14.66%)
Mutual labels:  web-components, custom-elements
Auto Complete Element
Auto-complete input values from server search results.
Stars: ✭ 213 (-8.19%)
Mutual labels:  web-components, custom-elements
Markdown Toolbar Element
Markdown formatting buttons for text inputs.
Stars: ✭ 160 (-31.03%)
Mutual labels:  web-components, custom-elements
Html Include Element
Easily include external HTML into your pages.
Stars: ✭ 143 (-38.36%)
Mutual labels:  web-components, custom-elements
Server Components
🔧 A simple, lightweight tool for composable HTML rendering in Node.js, based on web components.
Stars: ✭ 212 (-8.62%)
Mutual labels:  web-components, custom-elements
Ion Phaser
A web component to use Phaser Framework with Angular, React, Vue, etc 🎮
Stars: ✭ 152 (-34.48%)
Mutual labels:  web-components, custom-elements
Bolt
The Bolt Design System provides robust Twig and Web Component-powered UI components, reusable visual styles, and powerful tooling to help developers, designers, and content authors build, maintain, and scale best of class digital experiences.
Stars: ✭ 186 (-19.83%)
Mutual labels:  web-components, custom-elements
Vanilla Hamburger
Animated hamburger menu icons for modern web apps (1.8 KB) 🍔
Stars: ✭ 110 (-52.59%)
Mutual labels:  web-components, custom-elements
Preact Custom Element
Wrap your component up as a custom element
Stars: ✭ 212 (-8.62%)
Mutual labels:  web-components, custom-elements
Custom Elements
All about HTML Custom Elements
Stars: ✭ 188 (-18.97%)
Mutual labels:  web-components, custom-elements
Elm Canvas
A canvas drawing library for Elm
Stars: ✭ 124 (-46.55%)
Mutual labels:  web-components, custom-elements
Progressive Image Element
⚡️ <progressive-image> custom element
Stars: ✭ 231 (-0.43%)
Mutual labels:  web-components, custom-elements
Image Crop Element
A custom element for cropping a square image. Returns x, y, width, and height.
Stars: ✭ 115 (-50.43%)
Mutual labels:  web-components, custom-elements
Omi
Front End Cross-Frameworks Framework - 前端跨框架跨平台框架
Stars: ✭ 12,153 (+5138.36%)
Mutual labels:  web-components, custom-elements
Nutmeg
Build, test, and publish vanilla Web Components with a little spice
Stars: ✭ 111 (-52.16%)
Mutual labels:  web-components, custom-elements
Swiss
🇨🇭Functional custom elements
Stars: ✭ 169 (-27.16%)
Mutual labels:  web-components, custom-elements
Aybolit
Lightweight web components library built with LitElement.
Stars: ✭ 90 (-61.21%)
Mutual labels:  web-components, custom-elements
Dataformsjs
🌟 DataFormsJS 🌟 A minimal JavaScript Framework and standalone React and Web Components for rapid development of high quality websites and single page applications.
Stars: ✭ 95 (-59.05%)
Mutual labels:  web-components, custom-elements
Time Elements
Web component extensions to the standard <time> element.
Stars: ✭ 2,318 (+899.14%)
Mutual labels:  web-components, custom-elements
Shadow Dom In Depth
Everything you need to know about Shadow DOM
Stars: ✭ 191 (-17.67%)
Mutual labels:  web-components, custom-elements

ajax-form

HTML forms on performance-enhancing drugs.

Build Status npm license

Note: Ajax-form is not tied to Polymer. In fact, it has no dependencies at all, but should work just fine with Polymer or any other custom elements library. If you prefer to use a simple custom elements polyfill, ajax-form is also your best choice.

What's wrong with a traditional <form>?

  1. Form submission changes/reloads the page, and it's not trivial to properly prevent this.
  2. You can't send custom headers with a submitted form.
  3. You can't (easily) parse the server response after a form is submitted.
  4. Programmatically tracking invalid forms/fields is frustrating.
  5. You can't send form data as JSON.
  6. You have no opportunity to programmatically augment user-entered data before it is sent to the server.
  7. Custom form elements (such as those created using the web components spec) cannot be submitted using a traditional unadulterated <form>.

The ajax-form custom element augments a traditional <form> to provide additional features and solve the problems listed above. See the API documentation page for complete documentation and demos.

Installation

npm install ajax-form

Use

Use ajax-form just like you would use a traditional form, with the exception of the required is="ajax-form" attribute that you must include in your <form> element markup. Since ajax-form is a web component, you may need to include a web component polyfill, such as webcomponents.js to ensure browsers that do not implement the WC spec are able to make use of ajax-form. Ajax-form has no hard dependencies.

A very simple use of ajax-form looks just like a normal <form>, with the addition of an is attribute:

<form is="ajax-form" action="my/form/handler" method="post">
    <label>Enter your name: <input type="text" name="full_name"></label>
    ...
</form>

See the API documentation page for complete documentation and demos.

Integration

Are you developing a form field web component? Read the instructions below to ensure your field integrates properly with ajax-form.

Submitting

Your component will integrate nicely into ajax form provided your custom element exposes a value property that contains the current value of the field. If this is not true, then your custom field must ensure a native HTML form field is part of the light DOM. In either case, the element with the value property must also contain a name attribute. Your user/integrator will need to include an appropriate value for this field.

Validation

If your custom field exposes a native HTML form field in the light DOM, then there is nothing more to do - ajax-form will respect any validation that your user/integrator adds to the field. The constrain attribute(s) MUST be placed on the native HTML form field.

If your custom field does NOT expose a native HTML form field in the light DOM by default, and you want ajax-form to respect validation constraints, then you will need to include a little code to account for this. Here are the steps to follow:

  1. Add an opaque, 0x0 <input type="text"> field to the light DOM, just before your field.
  2. Add a customElementRef property to the input, with a value equal to your field.
  3. Ensure the validity of the input always matches the validity of your field. You can do this via the setCustomValidity method present on an HTMLInputElement.

See the setValidationTarget method in the <file-input> custom element source code for an example.

Testing

npm install
npm install -g grunt-cli
grunt
  • Running grunt without any parameters will test against a few locally installed browsers (see the codebase for details).

  • Running grunt shell:wctSauce will run tests against a number of browsers in SauceLabs. Ensure you have your SauceLabs username and key attached to the proper environment variables first.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].