Hi,

Try to read the cursor position in #prependJavaScript(), store it
temporarily somewhere, and set the position again in #appendJavaScript().
See
http://stackoverflow.com/questions/2897155/get-cursor-position-in-characters-within-a-text-input-field
http://stackoverflow.com/questions/512528/set-cursor-position-in-html-textbox
and many more in the web.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Nov 28, 2014 at 6:39 PM, ChambreNoire <a...@tentelemed.com> wrote:

> Hi,
>
> I was wondering if there's a way around the following problem - at least a
> slightly more elegant one than I came up with!
>
> When one adds an AjaxFormUpdatingBehavior("onkeyup") to a TextField, if
> during the update the source TextField is added to the AjaxRequestTarget
> the
> resulting behaviour is a TextField which periodically resets it's
> cursor/caret position to zero (depending on the Behavior's throttle
> settings). This is obviously problematic during typing.
>
> In my particular case, the TextField in question is within a container
> alongside the label, suffix and a bunch of status indicators (a super-field
> of sorts). These all react to changes in the textfield content. When I'm
> updating from outside it's not a problem but when the update comes from
> within as a result of an onKeyUp update, I add the container to the
> AjaxRequestTarget in order to get all the sub-components updated and thus
> end up with the aforementioned cursor issue.
>
> I have worked around this by performing partial updates in this specific
> case (all the siblings minus the offending textfield) and appending some
> JQuery to the AjaxRequestTarget in order to update the container css class
> but it's hardly ideal...
>
> Any thoughts?
>
> Thanks,
>
> CN
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/TextField-cursor-reset-mid-editing-tp4668582.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to