[Seaside] FormElement focus after an update

Lukas Renggli renggli at gmail.com
Wed Oct 3 14:44:07 UTC 2007

>     it's me searching wrongly or there is no javascript to query which
> element has focus in a form?

I don't think that's easily possible. Maybe CSS3 will help in a couple of years.

>     We want some input text #change to update some component but after the
> update the focus remains on it. Well in fact even better will be that the
> focus remains in the different input text that had caused the #change to
> trigger.
>     I've tried to emulate this by making the updater like this:
>     [:html|
>         html updater
>             id: self id;
>             evalScripts: true;

That's not necessary anymore. This is the default nowadays ;-)

>             callback:[:focusId| lastFocusId := focusId]
>             value: (html formElement
>                 id: (self at: aSymbol) inputElementId; id);
>             callback:[:v | (self at: aSymbol) model setValue: v]
>             value: (html formElement
>                         id: (self at: aSymbol) inputElementId;
>                         value);

I don't get this lines. What are they supposed to do?

>             callback:[:h| self renderInnerContentOn: h.
>             h script: (h formElement id: lastFocusId; focus)];
>             yourself
>     ]
>     but this does not work for some reason I dont get yet
>     Did anyone managed to recover focus state in a similar scenario? any
> idea on how to do it?

You can track the focus using JavaScript and onFocus/onBlur events on
all the required elements.


Lukas Renggli

More information about the Seaside mailing list