Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut for common apply/commit patterns #8

Open
dcore94 opened this issue Feb 12, 2020 · 1 comment
Open

Shortcut for common apply/commit patterns #8

dcore94 opened this issue Feb 12, 2020 · 1 comment

Comments

@dcore94
Copy link
Owner

dcore94 commented Feb 12, 2020

Very often for common input fields the apply/commit edi-functions are very boilerplate. Consider the following usual pattern:

target: "input[name=value]",
apply : (e,d,i)=>{ e.value = d.value },
commit: (e,d,i)=>{ d.value = e.value }

it could be useful to have a shortcut version which could even infer the assignments from the type of the DOM Element e and from the name of the input which needs to match the name of the key to access data object d..

As an example to be reasoned about:

target: "input[name=textinput]",
bind: auto /*auto for bidirectional, auto-apply or auto-commit for monodirectional binding*/
@dcore94
Copy link
Owner Author

dcore94 commented Feb 12, 2020

Another possibility is to make the key of object d dynamic and not dependant on the name of e:

target: "input[name=textinput]",
autobind: "key" //would resolve for a input of type text to apply : (e,d)=>{ e.value = d["key"]}, commit : (e,d)=>{ d["key"] = e.value }

Alternatives are autobind for bidirectional binding, autoapply, autocommit for monodirectional binding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant