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 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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 <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you Martin, for making that clear to me. Daniel -----Original Message----- From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Martin Ström Sent: Tuesday, May 22, 2007 3:23 AM To: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---