Skip to main content

FormRcController

Purpose

Submit and/or reset a form, using links/buttons that are outside the child DOM of the form.

Actions

ActionPurpose
resetReset the form
submitSubmit the form

Targets

TargetPurposeDefault
form (Optional)The form to target the controller's actions on-

Classes

ClassPurposeDefault
---

Values

ValueTypeDescriptionDefault
formSelector (Optional)StringThe CSS selector to find the form to remotely submit/reset-
submitMode (Optional)StringThe mode to submit the form using, either direct or request.

direct calls .submit() on the form without dispatching the submit event.
request synthesizes a normal submit event on the form, a submit event will still be fired and any listeners that modify the behaviours of the form will still run.

request

Events

EventWhenDispatched onevent.detail
submit [Native Browser Event]When the form is submitted, via the submit actionThe form target.-
reset [Native Browser Event]When the form is reset, via the reset actionThe form target.-

Side Effects

  • Adds event listeners for change or input (depending on the value of eventModeValue) to all <input> <textarea> and <select> elements in the controller's scope.
  • If the submitModeValue is request and the browser does not support .requestSubmit(), then the controller will use any existing submit buttons, or create a hidden submit button (which will be cleaned up on 'disconnect'), to submit the form by clicking on them.

See MSDN for details

How to Use

Option 1:

Put the controller in a scope that can see a formTarget, and wire up some links with actions to form-rc#submit,

Option 2:

Put the controller in a scope with some links with actions to form-rc#submit, and a CSS selector provided to the controller via formSelectorValue that it can use to find the form in the page,