Hi Everyone, I''m trying to get page.call to work and if i call something like page.call ''alert'', ''this is a test'' everything works ok, however when i try calling a function that i defined in application.js function my_function(){ alert(''this is a test''); } i get NameError (undefined local variable or method `my_function'' for #<ActionView::Base:. Any idea what i''m doing wrong here. Any input is greatly appreciated. Thank you, -- Posted via http://www.ruby-forum.com/.
On Oct 30, 6:03 pm, Wtn Tn <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi Everyone, > > I''m trying to get page.call to work and if i call something like > page.call ''alert'', ''this is a test'' > everything works ok, however when i try calling a function that i > defined in application.js > function my_function(){ > alert(''this is a test'');} i get NameError (undefined local variable or method `my_function'' for > > #<ActionView::Base:. > > Any idea what i''m doing wrong here. Any input is greatly appreciated. >What''s in your rjs file ? Fred> Thank you, > -- > Posted viahttp://www.ruby-forum.com/.
Frederick Cheung wrote:> On Oct 30, 6:03�pm, Wtn Tn <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> Any idea what i''m doing wrong here. Any input is greatly appreciated. >> > What''s in your rjs file ? > > Fred<script type="text/javascript"> function my_function(test){alert(test);} </script> page.call my_function -- Posted via http://www.ruby-forum.com/.
On Oct 30, 8:06 pm, Wtn Tn <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > On Oct 30, 6:03 pm, Wtn Tn <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > >> Any idea what i''m doing wrong here. Any input is greatly appreciated. > > > What''s in your rjs file ? > > > Fred > > <script type="text/javascript"> > function my_function(test){alert(test);} > </script> > page.call my_functionWell just as you wrote page.call ''alert'' and not page.call alert you need to write page.call ''my_function'' (I''m assuming that script tag isn''t actually in your rjs file as that clearly won''t work) Fred> -- > Posted viahttp://www.ruby-forum.com/.