"Element.extend is not a function" anybody?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

"Element.extend is not a function" anybody?

Sebastian Sastre-2
Hi there,

  I've see a couple of questions in the Prototype list about this but none with a direct
answer. I've also asked there but haven't had a single answer about that in two days. I'm starting to suspect I should know better what happen at load page time to see if everything is ok in this Seaside component.

  The thing is that a couple of days ago I've starting to see this message with
Firebug. Anybody see this sometimes? Under which situation could possibly be?

Message is:

Element.extend is not a function

I'm using

var Prototype = {
10 Version: '1.5.1_rc1',
...

in Firefox 2.0.0.4

   Debuggin from my own code just after it calls a

var candidate = $(anElementId)

   I followed this:

function $(element) {
1227 if (arguments.length > 1) {
1228 for (var i = 0, elements = [], length = arguments.length; i <
length; i++)
1229 elements.push($(arguments[i]));
1230 return elements;
1231 }
1232 if (typeof element == 'string')
1233 element = document.getElementById(element);
1234 return Element.extend(element);
1235}

and executing line by line I saw that it reaches line 1233 with the
appropriate (unextended) element and when executing line 1234 it says
"Element.extend is not a function"

Surely something basic is going on here but I'm unable to see what.
Does anybody see what is going on?

 thanks,

Sebastian
PS1: all this code is being executed starting from an invocation in the
onLoad() of the script of the page

PS2: I've already tried, and had the same results, with the last version of Prototype 1.5.1 downloaded today from it's site (and processed the ' chars to properly update the #prototypeJs method in SULibrary class).
 
PD3: is for the framework I've mentioned in the previous mail I've sent today

 

 

 

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: "Element.extend is not a function" anybody?

Sebastian Sastre-2
Hi, updates..
 
    I've found that it seems to be related to the onLoad method invocation. Somebody can confirm me if the onLoad event is triggered before or after the scripts of the page can be used (invoke it's objects, etc)?
 
    If I don't call objects on the onLoad (of the page, the one that is in the script part of <BODY>) then the error don't happen but I'm unable to understand exactly why it's behavior is that,
 
    thanks,
 

Sebastian Sastre

 


De: [hidden email] [mailto:[hidden email]] En nombre de Sebastian Sastre
Enviado el: Domingo, 10 de Junio de 2007 19:08
Para: 'Seaside - general discussion'
Asunto: [Seaside] "Element.extend is not a function" anybody?

Hi there,

  I've see a couple of questions in the Prototype list about this but none with a direct
answer. I've also asked there but haven't had a single answer about that in two days. I'm starting to suspect I should know better what happen at load page time to see if everything is ok in this Seaside component.

  The thing is that a couple of days ago I've starting to see this message with
Firebug. Anybody see this sometimes? Under which situation could possibly be?

Message is:

Element.extend is not a function

I'm using

var Prototype = {
10 Version: '1.5.1_rc1',
...

in Firefox 2.0.0.4

   Debuggin from my own code just after it calls a

var candidate = $(anElementId)

   I followed this:

function $(element) {
1227 if (arguments.length > 1) {
1228 for (var i = 0, elements = [], length = arguments.length; i <
length; i++)
1229 elements.push($(arguments[i]));
1230 return elements;
1231 }
1232 if (typeof element == 'string')
1233 element = document.getElementById(element);
1234 return Element.extend(element);
1235}

and executing line by line I saw that it reaches line 1233 with the
appropriate (unextended) element and when executing line 1234 it says
"Element.extend is not a function"

Surely something basic is going on here but I'm unable to see what.
Does anybody see what is going on?

 thanks,

Sebastian
PS1: all this code is being executed starting from an invocation in the
onLoad() of the script of the page

PS2: I've already tried, and had the same results, with the last version of Prototype 1.5.1 downloaded today from it's site (and processed the ' chars to properly update the #prototypeJs method in SULibrary class).
 
PD3: is for the framework I've mentioned in the previous mail I've sent today

 

 

 

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: "Element.extend is not a function" anybody?

Lukas Renggli
>     I've found that it seems to be related to the onLoad method invocation.
> Somebody can confirm me if the onLoad event is triggered before or after the
> scripts of the page can be used (invoke it's objects, etc)?
>
>     If I don't call objects on the onLoad (of the page, the one that is in
> the script part of <BODY>) then the error don't happen but I'm unable to
> understand exactly why it's behavior is that,

Generally onLoad should be only evaluate when everything has been
loaded, there are some browser that don't support this event properly
though.

   http://www.quirksmode.org/js/events_compinfo.html
   http://developer.mozilla.org/en/docs/DOM:window.onload

Are you sure that the load order of your Javascript code is correct?

Sometimes it helps to delay the execution of some events a little bit,
to make sure everything has settled.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: "Element.extend is not a function" anybody?

Sebastian Sastre-2
> > unable to understand exactly why it's behavior is that,
>
> Generally onLoad should be only evaluate when everything has
> been loaded, there are some browser that don't support this
> event properly though.
>
>    http://www.quirksmode.org/js/events_compinfo.html
>    http://developer.mozilla.org/en/docs/DOM:window.onload
>
> Are you sure that the load order of your Javascript code is correct?
>
> Sometimes it helps to delay the execution of some events a
> little bit, to make sure everything has settled.
>
> Lukas
>

Hi Lukas,

        well I'm starting to think that order could be the problem. First
another update: I've learn just now that #onLoad is "sent" only to BODY,
FRAMEsomething and other tag but not DIVs which was where I was trying to
use, so I've move the invocation to a <script> just after the div but the
problem is that if I let it there I start receive again the "Element.extend
is not a function".

        So.. Questions: 1) which are the "best practices" for guaranteeing
order? 2) how can I check or manipulate that load order?

        thanks,

Sebastian
PD: just to contextualize: what I'm trying to do is the initialization of a
js singleton that should be instantiated after everything is loaded. Besides
the initialization of this singleton (called ElementManager) there should be
"someone" (I'm unsuccesfully trying with a BODY onload) that add
someElements to it. Those someElements are objects that wrapps the prototype
DOM extended elements. One wrapper for each div that I've also made to wrap
seaside components of some class.

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: "Element.extend is not a function" anybody?

Lukas Renggli
>         So.. Questions: 1) which are the "best practices" for guaranteeing
> order?

Use updateRoot: of your root component to add the Javascript code
manually. Or make sure that you add your libraries in the proper order
and that their #selectorsToInclude are properly ordered.

2) how can I check or manipulate that load order?

FireBug. The files are evaluated from top to bottom.

> PD: just to contextualize: what I'm trying to do is the initialization of a
> js singleton that should be instantiated after everything is loaded. Besides
> the initialization of this singleton (called ElementManager) there should be
> "someone" (I'm unsuccesfully trying with a BODY onload) that add
> someElements to it. Those someElements are objects that wrapps the prototype
> DOM extended elements. One wrapper for each div that I've also made to wrap
> seaside components of some class.

onLoad should be fine. Maybe it is more save to do it as the last line
of your JavaScript code, if the code doesn't depend on the DOM to be
complete.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: "Element.extend is not a function" anybody?

Sebastian Sastre-2
> -----Mensaje original-----
> De: [hidden email]
> [mailto:[hidden email]] En nombre
> de Lukas Renggli
> Enviado el: Lunes, 11 de Junio de 2007 15:50
> Para: Seaside - general discussion
> Asunto: Re: [Seaside] "Element.extend is not a function" anybody?
>
> >         So.. Questions: 1) which are the "best practices" for
> > guaranteeing order?
>
> Use updateRoot: of your root component to add the Javascript
> code manually. Or make sure that you add your libraries in
> the proper order and that their #selectorsToInclude are
> properly ordered.
>
> 2) how can I check or manipulate that load order?
>
> FireBug. The files are evaluated from top to bottom.
>
> > PD: just to contextualize: what I'm trying to do is the
> initialization
> > of a js singleton that should be instantiated after everything is
> > loaded. Besides the initialization of this singleton (called
> > ElementManager) there should be "someone" (I'm unsuccesfully trying
> > with a BODY onload) that add someElements to it. Those someElements
> > are objects that wrapps the prototype DOM extended elements. One
> > wrapper for each div that I've also made to wrap seaside
> components of some class.
>
> onLoad should be fine. Maybe it is more save to do it as the
> last line of your JavaScript code, if the code doesn't depend
> on the DOM to be complete.
>
> Lukas
>
Yes ! Thank you so much Lukas! I'm using onLoad event in the root component
as you said and that made the trick. The rest was fine (library order and
#selectorsToInclude). I didn't need to use #updateRoot: by now.

I'll continue this with some js refactor I've found convenient now.

Thanks again Lukas,

Sebastian

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside