Closed marclaval closed 9 years ago
This sounds fine for me. Regarding the timeout I would really put a lower default value. sounds like 500ms, or even 250ms should be enough for me.
Nevertheless it should be configurable... which leads us to the question how to we provide user default parameters to a custom attribute handler ??
I would say that it could be done via a transparent way of providing associated data-custom-attr on the node itself
<input onupdate="{ctrl.onUpdate(event)}" data-onupdate-timeout="500" />
I am also fine with the name onupdate
. I also agree with @benouat that we should add a 2nd attribute to specifiy the default timer, but I would call it update-timeout
:
<input onupdate="{ctrl.onUpdate(event)}" update-timeout="1000" />
... and I would choose 500ms as default timeout as it is a reasonable time for usual client-side validation. Note: I would also create a separate playground sample as the current input sample is already cluttered, and this feature deserves some explanations. Btw. the sample could demonstrate textarea and input elements. Thx.
I'm not sure which is best update-timeout
or data-onupdate-timeout
.
data-*
exists to avoid cluttering and introducing compatibility problems with standard attributes.
It's unlikely in this specific case, but what if HTML* introduces an update-timeout attribute? It's less unlikely instead that a future standard might add an update event.
Anyway I think you should start considering ways to extend the core through plugins. update
event is useful but it belongs to the user space. The user might want to change not only the timeout, but how it relates with other events like blur, input or change, so I believe any custom attribute should be out of the core.
Another option you might consider is to include everything in one attribute, maybe with a modifier
<input onupdate="{ctrl.onUpdate(event) | updateTimeout: 1000}" />
I know @b-laporte will disagree :smiley: but I fully agree with you @piuccio when dealing with custom-attributes.... data-*
for the win !!
Everyone knows them, and everyone understand just by reading that it is a custom thing.
If we want to namespace hashspace proprietary attributes, we should do it for all of them in order to guarantee consistency. There are several in scope: model, ontap, onupdate, update-timeout, etc.
We'll have to discuss if and how we would do that: hsp:*
, hsp-*
, data-*
, nothing or something else.
About this PR, let's integrate it first and then we'll see if we refactor.
As a custom attribute, this PR adds a special event on and elements. It is fired 1s after a user stops typing in a field.
2 questions:
onupdate
the right name ?