BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
856 stars 130 forks source link

Disable all form elements #407

Closed trueqbit closed 6 years ago

trueqbit commented 6 years ago

Sometimes, a nice feature would be to disable all form elements. This might not seem useful at first, but when you have a big or complex form, then data-binding the disabled attribute at every input element, or conditionally showing alternatives soon becomes impractical and error-prone.

So, the idea is that every data-bound input element would observe a disabled parent (form).

Would this be something that could be easily achieved by the jsviews library?

eugene-panferov commented 6 years ago

maybe it should be: set AttrX to ValueY in the subtree of the given tag

BorisMoore commented 6 years ago

I don't think that is do-able in any straightforward and robust way.

You cannot observe an HTML attribute. JsViews observability is for observable changes to data. An HTML form disabled attribute/property can be changed directly with out triggering any cross-browser mutation event.

If your scenario involves having the form disabled state be data-driven, then you can observe that change and data-bind all form input elements disabled properties to the same data event.

BorisMoore commented 6 years ago

Closing this, as not do-able.