When submitting forms, if an error occurs, by default, Mrujs will use a library called “morphdom” to render the new state of the page.
Sometimes, you may want to “scope” what morphdom will
change. By default, morphdom targets
may not be desireable for all circumstances.
On the submitting form you can do the following:
and this will scope changes to only the form. If, however, you would like to scope changes to an external element, you can pass a valid querySelector string like so:
<div id="form-errors"></div> <form data-ujs-morph-root="#form-errors"></form>
This means morphdom will only show changes to the children
morph-root cannot be found, mrujs will fallback to
morphing the entire body of the page.
data-ujs-morph-root only applies to error
handling. Successful form submissions are expected to
redirect and their HTML / navigation will be piped through