[Ror-es] cursor por defecto en un campo
Fernando Seves
fernando.seves at gmail.com
Mon Sep 3 20:11:47 GMT 2007
Muchas gracias a todos. A final con JQuery uso
$("input:first").focus();
que selecciona el primer campo por defecto del formulario.
Muchas gracias y un saludo a la lista
El día 3/09/07, William Betancur <ruby-forum-incoming at andreas-s.net>
escribió:
>
> Damian Janowski wrote:
> > On 9/3/07, Fernando Seves <fernando.seves at gmail.com> wrote:
> >>
> >> Buenas
> >>
> >> Como podr�a poner el cursor por defecto en el campo login al cargar la
> >> pagina? Existe alg�n helper para esto?
> >>
> >> <%= text_field 'user', 'login', :class => "input" %>
> >
> > Considerando que est�s incluyendo Prototype, debajo de todo el
> formulario:
> >
> > <%= javascript_tag "Element.focus('user_login')" %>
> >
> > Sin Prototype:
> >
> > <%= javascript_tag "if ((e = document.getElementById('user_login')) &&
> > e.focus) e.focus();" %>
> >
> > Pas�ndolo a un helper, por supuesto ;)
> >
> > Saludos
>
> una forma de hacerlo para todos los formularios es agregando este codigo
> en layouts/aplication.rhtml
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
> <head>
> <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
> <title>Parking</title>
> <%= stylesheet_link_tag 'scaffold' %>
> <%= javascript_include_tag :defaults %>
>
> <script language="JavaScript">
> <!-- Begin
> function setFocus() {
> if (document.forms.length > 0) {
> var field = document.forms[0];
> for (i = 0; i < field.length; i++) {
> if ((field.elements[i].type == "text") ||
> (field.elements[i].type == "textarea")
> || (field.elements[i].type.toString().charAt(0) == "s")) {
> document.forms[0].elements[i].focus();
> break;
> }
> }
> }
> }
> // End -->
> </script>
>
> </head>
>
> esto es js.
>
> saludos
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ror-es mailing list
> Ror-es at lists.simplelogica.net
> http://lists.simplelogica.net/mailman/listinfo/ror-es
>
--
skype >> arbaa4
www.sevtov.com
fernando.seves at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.simplelogica.net/pipermail/ror-es/attachments/20070903/6cfea913/attachment.htm
More information about the Ror-es
mailing list