Olie D.
2007-Oct-09 20:37 UTC
[N00b] Javascript stopped wrking when move to application.js
I originally had my view look something like: <script language="JavaScript"> <!-- Begin function foo(obj) [...etc] // End --> </script> <% @heading = "Bugs" %> <%= link_to ''Bug table'', :action => ''bug_table'' %> <p /> <table> <% for bug in @bugs %> <tr> [etc., table] But then I changed it to: <% @heading = "Bugs" %> <%= javascript_include_tag :defaults %> <-- new line <%= link_to ''Bug table'', :action => ''bug_table'' %> <p /> <table> <% for bug in @bugs %> <tr> [etc., table] and moved everything between <script> and </script> into public/javascripts/application.js. Back when all the JS was in my view.rhtml, everything worked fine. Now that it''s in application.js, none of the functions do anything -- I suspect that they''re not being loaded, somehow. When I view source for the rendered page, I see <script src="/javascripts/prototype.js?1191270082" type="text/javascript"></script> <script src="/javascripts/effects.js?1191270082" type="text/javascript"></script> <script src="/javascripts/dragdrop.js?1191270082" type="text/javascript"></script> <script src="/javascripts/controls.js?1191270082" type="text/javascript"></script> <script src="/javascripts/application.js?1191286272" type="text/javascript"></script> <a href="/bugs/bug_table">Bug table</a> <p /> <table> [etc.] And, when I load up application.js?1191286272 and view its source, sure enough, there''s my java-script, just as I''d expect. So... what am I doing wrong? Thanks! P.S. Tried to Google + seach archives for this but, apparently, my search-fu is weak -- Google got me nothing, while this-forum returned 100s of hits, none of which seemed to address this issue (I searched on +javascript +"not.loaded") Hints there would be helpful, too :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Olie D.
2007-Oct-23 16:48 UTC
Re: [N00b] Javascript stopped wrking when move to application.js
Ping? 2 weeks and no one knows...? Summary: * When I have the javascript code in my aplication.rhtml, it all works fine. * When I move javascript code to public/javascripts/application.js and insert %= javascript_include_tag :defaults %> into my application.rhtml, none of the javascript calls work. * http://locahost:3000/javascripts/application.js returns a page that contains all of the expected javascript. Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2007-Oct-23 17:29 UTC
Re: [N00b] Javascript stopped wrking when move to application.js
Go get Firebug: http://www.getfirebug.com You''re obviously including the javascript into your page, it''s just not getting initialized properly. Jason On 10/23/07, Olie D. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Ping? 2 weeks and no one knows...? > > Summary: > > * When I have the javascript code in my aplication.rhtml, it all works > fine. > * When I move javascript code to public/javascripts/application.js and > insert %= javascript_include_tag :defaults %> into my application.rhtml, > none of the javascript calls work. > * http://locahost:3000/javascripts/application.js returns a page that > contains all of the expected javascript. > > Thanks! > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Olie D.
2007-Oct-23 18:08 UTC
Re: [N00b] Javascript stopped wrking when move to application.js
Jason Roelofs wrote:> Go get Firebug: http://www.getfirebug.com > You''re obviously including the javascript into your page, it''s just not > getting initialized properly. > JasonOk, this just gets weirder & weirder... Firebug shows that the javascript is loaded & all seems well. (Maybe I''m not clear what I need to check to see that it''s "initialized"...?) Just as a sanity check, I put the js back in the main file, and verified: sure enough, all works correctly. Pulled it back out, no workie. Ok, so where in firebug do I look to see what is different? For what am I looking? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2007-Oct-23 18:40 UTC
Re: [N00b] Javascript stopped wrking when move to application.js
If there are no errors in the Console, then we''ll need to see what you are trying to do. The code you''ve posted doesn''t help with solving the problem. Jason On 10/23/07, Olie D. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Jason Roelofs wrote: > > Go get Firebug: http://www.getfirebug.com > > You''re obviously including the javascript into your page, it''s just not > > getting initialized properly. > > Jason > > Ok, this just gets weirder & weirder... > > Firebug shows that the javascript is loaded & all seems well. (Maybe > I''m not clear what I need to check to see that it''s "initialized"...?) > > Just as a sanity check, I put the js back in the main file, and > verified: sure enough, all works correctly. Pulled it back out, no > workie. > > Ok, so where in firebug do I look to see what is different? For what am > I looking? > > Thanks! > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Oct-23 19:15 UTC
Re: [N00b] Javascript stopped wrking when move to application.js
On 23 Oct 2007, at 19:08, Olie D. wrote:> > Just as a sanity check, I put the js back in the main file, and > verified: sure enough, all works correctly. Pulled it back out, no > workie. > > Ok, so where in firebug do I look to see what is different? For > what am > I looking? >Set breakpoints and step through them. Fred> Thanks! > -- > Posted via http://www.ruby-forum.com/. > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk- > unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > For more options, visit this group at http://groups.google.com/ > group/rubyonrails-talk?hl=en > -~----------~----~----~----~------~----~------~--~--- >
Olie D.
2007-Oct-23 20:25 UTC
Re: [N00b] Javascript stopped wrking when move to application.js
Jason Roelofs wrote:> If there are no errors in the Console, then we''ll need to see what you > are > trying to do. The code you''ve posted doesn''t help with solving the > problem. > > JasonI''m using "show fully-HTML-savvy tool-tips (so BR, B, I tags, etc)" code that I got from a tutorial on the web. Again, if I put the javascript in the main source, it all works perfectly. If I use the javascript tags & js in its own file, it doesn''t work. I''m not sure what parts you want to see. Should I upload a zip-folder with some key bits? Also, Fred, I''m not sure what you''re telling me about breakpoints. I''m new to firebug, could you be explicit? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2007-Oct-23 20:51 UTC
Re: [N00b] Javascript stopped wrking when move to application.js
Basically, you''re code is not executing. I get the feeling that it''s supposed to "just run". This won''t happen in a file because the DOM is not yet loaded when the script is pulled in. It works in-line because javascript is run *after* the DOM is loaded. You''ll need to wrap the code up in a function that gets called onload (any time after DOM is loaded, really). Jason On 10/23/07, Olie D. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Jason Roelofs wrote: > > If there are no errors in the Console, then we''ll need to see what you > > are > > trying to do. The code you''ve posted doesn''t help with solving the > > problem. > > > > Jason > > I''m using "show fully-HTML-savvy tool-tips (so BR, B, I tags, etc)" code > that I got from a tutorial on the web. > > Again, if I put the javascript in the main source, it all works > perfectly. If I use the javascript tags & js in its own file, it > doesn''t work. > > I''m not sure what parts you want to see. Should I upload a zip-folder > with some key bits? > > Also, Fred, I''m not sure what you''re telling me about breakpoints. I''m > new to firebug, could you be explicit? > > Thanks! > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---