[Seaside] Validating inputs before calling callback using AJAX serialization
Esteban A. Maringolo
emaringolo at gmail.com
Fri Jan 12 18:10:41 UTC 2018
Hi all,
I'm trying to find a clean and "proper" way of dealing with the validation
of user entered values in forms _before_ they hit the callback block.
And based on such validation result be able to respond one script or
another.
Let's say I have something like
html textInput
onChange: (html jQuery ajax serializeThis);
script: (html jQuery script: [:s | "fancy things that modify the web UI"
];
callback: [:value | self doSomethingWithValue: value]
The problems with that are:
a) I can't "sanitize" the input before it reaches the callback block, I
have to do it within the callback block.
b) I have no way to return one script for a successful validation, and one
for a failing one.
I'd like something like
A)
html textInput
onChange: (html jQuery ajax
serializeThisValidating: validationBlock
successScript: [:s | "fancy things that modify the web UI" ]
failureScript: [:s | "modify the web UI reporting the failure" ]);
callback: [:value | self doSomethingWithValue: value]
or...
B)
html textInput
onChange: (html jQuery ajax serializeThis);
callback: [:value | self doSomethingWithValue: value ]
validation: aBlock
successScript: [:s | "fancy things that modify the web UI" ]
failureScript: [:s | "modify the web UI reporting the failure" ].
I think that the A option is the best alternative, since all the "special
handling" will happen in the context of the JQAjax and maybe a special kind
of JSAjaxCallback).
Also I don't know how this would work in the context of _several_ validated
callbacks, but I plan to make it work in the context of #serializeThis only.
But I'm sure there is a simpler way of achieving this, since I tend to make
things complicated.
Any suggestions?
Esteban A. Maringolo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20180112/0f680ea4/attachment.html>
More information about the seaside
mailing list