Thanks a lot for taking the time to answer in this precise way!

Joannes

2010/3/16 T.J. Crowder <t...@crowdersoftware.com>

> Hi,
>
> > I tryed to change this line :
> [snip]
> > into this one :
> >
> > $F('recherchefiche') = TexteDefautRechercheFiche;
> >
> > but it don't seem to work...
>
> `$F` is for *retrieving* the value of a field; in JavaScript, a
> function call can't be the left-hand side of an assignment statement.
>
> For setting a field value, you want the Form.Element#setValue
> function[1], e.g.:
>
> $('recherchefiche').setValue(TexteDefautRechercheFiche);
>
> Some other comments:
>
> > Event.observe(window, 'load', InitialisationPage);
>
> That works, but you might also consider using the Prototype dom:loaded
> event instead.[2]
>
> > Event.observe(window, 'resize',
> > this.InitialisationPage.bindAsEventListener(this));
>
> You don't need bindAsEventListener here (you almost never do[3]). Just
> #bind[4]. (In fact, in the actual code you quoted, you don't need
> either because you're not using `this` within `InitialisationPage`,
> and because `this` doesn't (seem) to have any special value where
> you're making the call.)
>
> >         Event.observe('recherchefiche', 'focus', function(){
> >                 if(document.getElementById("recherchefiche").value ==
> > TexteDefautRechercheFiche)
> > document.getElementById("recherchefiche").clear();
> >         });
>
> Prototype ensures that the `this` value within an event handler
> references the element that you're observing (unless you force it to
> be something else by using #bind on the function), so you could
> rewrite that as:
>
> Event.observe('recherchefiche', 'focus', function() {
>     if (this.getValue() == TexteDefautRechercheFiche) {
>        this.clear();
>    }
> });
>
> Or the very similar but *slightly* briefer:
>
> $('recherchefiche').observe('focus', function() {
>    if (this.getValue() == TexteDefautRechercheFiche) {
>        this.clear();
>    }
> });
>
> [1] http://api.prototypejs.org/dom/form/element.html#setvalue-class_method
> [2] http://prototypejs.org/api/document/observe
> [3]
> http://proto-scripty.wikidot.com/prototype:tip-you-probably-don-t-need-bindaseventlistener
> [4] http://api.prototypejs.org/language/function.html#bind-instance_method
>
> HTH,
> --
> T.J. Crowder
> Independent Software Consultant
> tj / crowder software / com
> www.crowdersoftware.com
>
> On Mar 16, 2:40 pm, Joannes De KOSTER <joannes.dekos...@gmail.com>
> wrote:
> > Hello,
> >
> > I am trying to learn the use of prototye in stead of using regular
> > javascript. I would like to know how to replace the following syntax
> > with one from prototype. After a few tryouts, i can't seem to get this
> > work :/
> >
> > <script type="text/javascript">
> >
> > // textes par défaut zones de saisie
> > var TexteDefautRechercheFiche = "Recherche par avatar, compte, email
> > ou userid";
> >
> > Event.observe(window, 'load', InitialisationPage);
> >
> > Event.observe(window, 'resize',
> > this.InitialisationPage.bindAsEventListener(this));
> >
> > function InitialisationPage()
> > {
> >
> >         // gestion de la valeur par défaut pour la zone de recherche de
> > fiches joueurs
> >
> >         document.getElementById("recherchefiche").value =
> > TexteDefautRechercheFiche;
> >
> >         Event.observe('recherchefiche', 'focus', function(){
> >                 if(document.getElementById("recherchefiche").value ==
> > TexteDefautRechercheFiche)
> > document.getElementById("recherchefiche").clear();
> >         });
> >
> > }
> >
> > </script>
> >
> > The html part is simple :
> >
> > <input type="text" name="recherchefiche" id="recherchefiche"
> > class="saisietextestandard" value="" />
> >
> > I tryed to change this line :
> >
> > document.getElementById("recherchefiche").value =
> > TexteDefautRechercheFiche;
> >
> > into this one :
> >
> > $F('recherchefiche') = TexteDefautRechercheFiche;
> >
> > but it don't seem to work...
> >
> > Any idea?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> prototype-scriptacul...@googlegroups.com.
> To unsubscribe from this group, send email to
> prototype-scriptaculous+unsubscr...@googlegroups.com<prototype-scriptaculous%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
>


-- 

--

Sincères salutations.

Joannes De KOSTER
Directeur

Société DEFI SUD

Expert AccessiWeb en Evaluation
Développeur Certifié Macromedia Dreamweaver MX

10 Parc Club du Millénaire
1025 rue Henri Becquerel
34000 Montpellier
T : 04 67 20 45 51
P : 06 16 26 43 28
www.defi-sud.com

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to