Care to share your revelation with me/us? Is it because when defined with "var" no global variable is defined and so the class instance (STUFF) is not accessible in the HTML?
Cheers, Daniel On 21.01.2010, at 00:21, hairbo wrote: > Hey Aaron, > > Thanks for the reply. Let me just say...OMFG. > > I did (and usually have done) this: > > window.addEvent('domready',function(){ > var STUFF = new MyClass(); > }); > > ...instead of this: > > window.addEvent('domready',function(){ > STUFF = new MyClass(); > }); > > sigh. Thanks for the help > > > > On Jan 20, 4:39 pm, Aaron Newton <aa...@iminta.com> wrote: >> On Wed, Jan 20, 2010 at 2:36 PM, hairbo <bmuel...@gmail.com> wrote: >>> Okay, there may be things here that I don't understand, so >>> apologies... >> >>> 1) I thought this function was supposed to be able to handle a mix of >>> HTML and JS, and would be smart enough to evaluate any JS it finds in >>> the returned data. If this is the case (as it does appear to be), >>> then removing the script tag would surely break. >> >> This is the case; it should script the scripts from the response (which is >> why you don't see it if you log the response html) and then evaluates it >> after updating your element. >> >> >> >> >> >>> 2) It turns out that my problem was the JS I had returned wasn't being >>> evaluated because it didn't recognize a Mootools class I had >>> instantiated. This I don't think I understand. I created a class, >>> like this: >> >>> var MyClass = new Class({ >> >>> ...bla bla bla... >> >>> }); >> >>> MyClass.implement (new Options, new Events); >> >>> ...then, I did this in the page: >> >>> window.addEvent('domready',function(){ >>> var STUFF = new MyClass(); >>> }); >> >>> I expected that the JS being returned by my Ajax page would be able to >>> do this: >> >>> STUFF.subMethod(); >> >>> ...but that failed. I don't get why it failed, though, since I'm able >>> to just create a regular JS function on the page, and reference >>> *that*, like this: >> >>> function myFunction () {} >> >>> ...and then my JS in the AJAX response is this: >>> myFunction() >> >>> Why does that second example work, and the first not work? What basic >>> JS principle am I missing? >> >> This is where we can't help you so much. You need to use console (firebug) >> and start logging things you are expecting to be present to get to the >> bottom of it. I can say that Form.Request is well tested and works (I use it >> constantly)...