I want to do simple stuff. In my controller I have this: render :update do |page| page.replace_html ''scripts'', :partial => ''scripts'', :locals => {:question => @question} end And in the partial I have this: <% if question.sound %> Sound loaded! <script src="/javascripts/soundmanager2-jsmin.js?1264193894" type="text/javascript" /> <script src="/javascripts/soundmanager2-rails.js?1264193894" type="text/javascript" /> <script type="text/javascript"> soundManager.url = ''/soundmanager2.swf''; soundManager.debugMode = false; soundManager.consoleOnly = false; </script> <script type="text/javascript"> soundManager.onload = function() { soundManager.createSound("question_sound", "<%url_for_file_column(''question'', :sound) %>"); } </script> <% end %> Well, when I run it, the message "Sound loaded!" appears, but the scripts are not rendered (I inspect the elements with Chrome and with Firebug, and the scripts do not appear). Is there anything wrong when I try to do this? Is there a way to make this work? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yuri Albuquerque wrote:> I want to do simple stuff. In my controller I have this: > > render :update do |page| > page.replace_html ''scripts'', :partial => ''scripts'', :locals => > {:question => @question} > end > > And in the partial I have this: > > <% if question.sound %> > Sound loaded! > <script src="/javascripts/soundmanager2-jsmin.js?1264193894" > type="text/javascript" /> > <script src="/javascripts/soundmanager2-rails.js?1264193894" > type="text/javascript" /> > <script type="text/javascript"> > soundManager.url = ''/soundmanager2.swf''; > soundManager.debugMode = false; > soundManager.consoleOnly = false; > </script> > <script type="text/javascript"> > soundManager.onload = function() { > soundManager.createSound("question_sound", "<%> url_for_file_column(''question'', :sound) %>"); > } > </script> > <% end %> > > Well, when I run it, the message "Sound loaded!" appears, but the > scripts are not rendered (I inspect the elements with Chrome and with > Firebug, and the scripts do not appear). > > Is there anything wrong when I try to do this? Is there a way to make > this work?Why not just call the script file from a <script> tag instead of replace_html? In general, your JavaScript should be coming from static external files. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> Why not just call the script file from a <script> tag instead of > replace_html? In general, your JavaScript should be coming from static > external files. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.orgWell, now I tried. I have tried this on my view: <script type="text/javascript"> var q_sound=''<%= url_for_file_column(''question'', :sound) %>''; </script> <script type="text/javascript"> //<![CDATA[ soundManager.onload = function() { if(q_sound!='''') soundManager.createSound("question_sound", q_sound); } //]]> </script> And this on the controller: page << ''soundManager.unload();'' page << "q_sound = ''#{url_for_file_column(''question'', :sound)}'';" page << ''soundManager.load();'' But when I test, it return this error: RJS error: Error: SoundManager.getSoundById(): sID is null/undefined I know why this error is ocurring (because soundManager is trying to load q_sound even if it is empty), but I don''t know how to solve. Any tips? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yuri Albuquerque wrote:> >> Why not just call the script file from a <script> tag instead of >> replace_html? In general, your JavaScript should be coming from static >> external files. >> >> Best, >> -- >> Marnen Laibow-Koser >> http://www.marnen.org >> marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > Well, now I tried. I have tried this on my view: > <script type="text/javascript"> > var q_sound=''<%= url_for_file_column(''question'', :sound) %>''; > </script> > <script type="text/javascript"> > //<![CDATA[ > soundManager.onload = function() { > if(q_sound!='''') soundManager.createSound("question_sound", q_sound); > } > //]]> > </script> > > And this on the controller: > > page << ''soundManager.unload();'' > page << "q_sound = ''#{url_for_file_column(''question'', :sound)}'';" > page << ''soundManager.load();'' > > But when I test, it return this error: > > RJS error: > > Error: SoundManager.getSoundById(): sID is null/undefined > > I know why this error is ocurring (because soundManager is trying to > load q_sound even if it is empty), but I don''t know how to solve. > > Any tips?Follow the advice I already gave. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.