A data-wp-input
directive for two-way data binding
#62332
Replies: 5 comments 3 replies
-
Thanks for creating this! It does't provide anything that cannot already be implemented, but it would save some repetitive code. It might also prevent bugs because change/input handlers would not need to be implemented for everything to connect to the store. One way to think about it is as the inverse of the The most common use case would likely be for |
Beta Was this translation helpful? Give feedback.
-
How would be an example of integrating input validation with those directives? |
Beta Was this translation helpful? Give feedback.
-
I like it 😄👏 I like that it is different from |
Beta Was this translation helpful? Give feedback.
-
+1 from me to this idea; I had to read the API docs twice to make sure I wasn't missing what seemed like a standard feature for frameworks like this. Having to write my own code for it was fine with a single form element, but with anything more complex it would get repetitive very quickly. |
Beta Was this translation helpful? Give feedback.
-
What about this feature, will it be implemented? |
Beta Was this translation helpful? Give feedback.
-
As per @sirreal suggestion, having a directive that eases the control of
<input>
elements would be interesting, so it is not necessary to write a callback to handle value updates.The directive could just point to a property in the state or context:
No event handler would be necessary to write something like this:
It could even handle input types so you don't need to parse the value:
The directive is mostly intended to be used in
<input>
elements (maybe<textarea>
as well), so I thought about naming itdata-wp-input
. We can choose other names, though. 😄Another name that comes to my mind is
data-wp-control
, as that's the word used in the MDN documentation to describe<input>
elements.Let me know what you think. 😊
Beta Was this translation helpful? Give feedback.
All reactions