[Project_owners] Javascript!

Ezequiel Calderara ezechico at gmail.com
Sun Oct 26 10:56:23 PDT 2008


Also, is always preferable to have named variables instead of a single
letter ones...

what does p stands for? u have to look for the definition of that variable
or the assignment...
the code, at least for me, should be semantic.. and easy to understand...

On Sun, Oct 26, 2008 at 6:16 AM, joe ertaba <belaviyo at gmail.com> wrote:

> Thank you very much :)
>
> So why it isn't better to use variable name (p in my case) always
> instead of "this" ?
>
> On 10/26/08, Matthew Wilson <matthew at mjwilson.demon.co.uk> wrote:
> > When p.Initial is called, "this" does not refer to p, but "window".
> >
> > See
> >
> https://developer.mozilla.org/en/DOM/element.addEventListener#The_value_of_this_within_the_handler
> >
> >
> > Matthew
> >
> > joe ertaba wrote:
> >> Hi Matthew
> >>
> >> I dont think that this is a case , here is example:
> >>
> >> ----XUL---
> >> <label value="Put your XUL here!" id="iddd"
> >> onclick="
> >> *    p.MyFuction();*
> >> "
> >> />
> >> -------
> >> ----JavaScript---
> >> var p = {
> >>     element1 : "" ,
> >>     Initial : function(){
> >>         this.element1 = document.getElementById("iddd");
> >>     },
> >>     MyFuction : function(){
> >>         this.element1.value="some text";
> >>     }
> >> }
> >>
> >> *window.addEventListener("load", p.Initial, true); *
> >> -------
> >>
> >> In this example I use p.Initial in proper time, but still nothing
> >> happens when click on label!
> >
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> https://www.mozdev.org/mailman/listinfo/project_owners
>



-- 
______
Ezequiel.

Http://www.ironicnet.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mozdev.org/pipermail/project_owners/attachments/20081026/5d377e5e/attachment.html>


More information about the Project_owners mailing list