Thank you Martin, for making that clear to me.
Daniel -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Martin Ström Sent: Tuesday, May 22, 2007 3:23 AM To: [email protected] Subject: [Rails-spinoffs] Re: Getting a variable back from Event.observe Right now your controller variable is local and only lives inside of the init function. The easiest way to make it global (and therefore be able to access it later) is to initialize it outside the function: var controller, init = function() { controller = new Image('test-image); } controller should now be accessable after init() has run. A nicer way of doing this would be to wrap it into a namespace like var Page = { controller: null, initialize: function() { this.controller = new Image('...'); } } Event.observe(window, 'load', Page.initialize.bind(Page)); // after page is loaded you can access the controller using Page.controller Ciao Martin On 5/22/07, Daniel Eben Elmore <[EMAIL PROTECTED]> wrote: > > Given this: > > var init = function () { controller = new Imager('test-image'); }; > > Event.observe(window,'load',init); > > > How can I get a handle or "access" to the controller object I created? > > > Thanks! > Daniel > > > > > > -- burnfield.com/martin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
