[Seaside] FormElement focus after an update

Sebastian Sastre ssastre at seaswork.com
Wed Oct 3 14:58:26 UTC 2007


Sorry, thanks for ask, I comment code now:

    [:html|
        html updater
		"Set the id of the div wrapping the component"
            id: self id;

		"Developer being unupdated"
            evalScripts: true;

		"A callback to store in the lastFocusId instVar of the
receiver
		the id of the input text tag in the DOM that is trigering
		the #change event that calls this updater as reaction"
            callback:[:focusId| lastFocusId := focusId]
            value: (html formElement  
                id: (self at: aSymbol) inputElementId; id);
		
		"A callback to set a fresh value of the model of the 
		(sub)component that renders the input text tag with."
            callback:[:v | (self at: aSymbol) model setValue: v]
            value: (html formElement  
                        id: (self at: aSymbol) inputElementId;
                        value);
		"The updater callback for rendering the internal html of
		the receiver (all but wrapping stuff)"
            callback:[:h| self renderInnerContentOn: h.

		"A script that tries to set at update time the focus in 
		the element (the last #change *neighter*) that was the one 
		that has caused the #change that has caused this updater to
be executed"
            h script: (h formElement id: lastFocusId; focus)];
            yourself
    ]

	I hope making myself to be understable :P

Sebastian Sastre

> -----Mensaje original-----
> De: seaside-bounces at lists.squeakfoundation.org 
> [mailto:seaside-bounces at lists.squeakfoundation.org] En nombre 
> de Lukas Renggli
> Enviado el: Miércoles, 03 de Octubre de 2007 11:44
> Para: Seaside - general discussion
> Asunto: Re: [Seaside] FormElement focus after an update
> 
> >     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
> 
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the seaside mailing list