[Seaside-dev] Focus

phil at highoctane.be phil at highoctane.be
Mon Jun 2 12:42:50 UTC 2014


On Mon, Jun 2, 2014 at 2:32 PM, Sven Van Caekenberghe <sven at stfx.eu> wrote:

> I do it like this:
>
> renderJavaScriptOn: html
>         | target |
>         target := self username
>                 ifNil: [ 'form #username' ]
>                 ifNotNil: [ 'form #password' ].
>         html script: (html jQuery: target) triggerFocus
>
> for a login component (the focus is set on the username field unless it is
> filled in, in which case the focus goes to the password field).
>

jQuery indeed. Now, script: will do that in place. So, if you are loading
things at the bottom of the script, it will fail.

I wondered what is your practice regarding those things.

Now, I am putting things in <head> so that everything works as advertised.

Phil



> On 02 Jun 2014, at 14:27, Diego Lont <diego.lont at delware.nl> wrote:
>
> > Hi all,
> >
> > I must miss very simple, because I fail to set the focus of my element.
> I tried stripping my component, but still it does do nothing. I think the
> problem lies in the generated javascript.
> > This is the code that I use to generate it:
> > renderContentOn: canvas
> > …
> >       | textInput |
> >       textInput := canvas textInput.
> >       canvas document addLoadScript: 'document.getElementById("',
> textInput ensureId ,'").focus()'.
> >       textInput on: #userid of: self
> > ...
> > And this is the resulting javascript:
> >       /*<![CDATA[*/function
> onLoad(){"document.getElementById(\"id1\").focus()";};/*]]>*/
> >
> > When I look at this javascript, I see that my parameter (“id”) is
> encoded. This is probably why it does not find the element indicated …
> >
> > Does anyone know how I can solve this?
> >
> > Cheers,
> > Diego_______________________________________________
> > seaside-dev mailing list
> > seaside-dev at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>
> _______________________________________________
> seaside-dev mailing list
> seaside-dev at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside-dev/attachments/20140602/edec2456/attachment.htm


More information about the seaside-dev mailing list