Not loading on ready [was: Re: [amber-lang] where is loadAmber defined?]

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

Not loading on ready [was: Re: [amber-lang] where is loadAmber defined?]

larrry
Turns out that the problems I was having were similar to my earlier problems loading amber in dev, which is to say that I need the line:
       <script src="codetalker.js" type="text/javascript"></script>
in the <body> section rather than in <head>.

I don't know if this is a bug or not, but if it might be, here are more details about the error I get on loading, which is: 

Uncaught Type Error: can not read property 'canHaveChildren' of undefined. 

I used this to build the js file:
../bin/amberc -d  Canvas.st Codetalkers.st codetalker
(I don't know why I had to add Canvas explicitly but it didn't get added otherwise). 

then I added manually 
smalltalkReady = function() {
      smalltalk.CTCodeTalkers._open();
}
I put it near the end of my js file, just before init. Also put it on the last line before it gets used in 
if(this.smalltalkReady) {
    this.smalltalkReady();
}
I get the same error either way.
The error occurs right in my _open(). The actual line is marked below with >>>.
smalltalk.addMethod(
unescape('_open'),
smalltalk.method({
selector: unescape('open'),
category: 'initialize',
fn: function (){
var self=this;
>>> smalltalk.send(smalltalk.send(self, "_new", []), "_appendToJQuery_", [smalltalk.send("body", "_asJQuery", [])]);
return self;},
args: [],
source: unescape('open%0A%09self%20new%20appendToJQuery%3A%20%27body%27%20asJQuery.'),
messageSends: ["appendToJQuery:", "new", "asJQuery"],
referencedClasses: []
}),
smalltalk.CTCodeTalkers.klass);

That's it. Again, it works fine if I load my amber code in the <body> but not if it's in <head>.

Cheers.

On Tue, Oct 25, 2011 at 5:30 PM, Nicolas Petton <[hidden email]> wrote:
loadAmber is in js/amber.js and takes care of loading files for you.
However, if you don't use it, you can call your function like this:

smalltalkReady = function() {
       //Do anything you want here
}

All you have to make sure is that you define this before loading amber
(it will be called in init.js).

HTH,
Nico

On Tue, 2011-10-25 at 17:21 -0400, Larry White wrote:
> I'm using the load amber function to execute my amber code on page
> load and it works in dev mode, but when I switched to deployment mode
> I get "Uncaught Reference: loadAmber is not defined.
>
> To create my deployment js I followed the instructions on the mailing
> list to create a single js file like so
>
> cat js/boot.js js/Kernel.deploy.js js/Canvas.deploy.js
> js/MYCODE.deploy.js js/init.js > js/mycode.js
>
> Is there something missing from this list?
>
> thanks.