I've searched for an answer to this question but haven't had any success. I am using the audio.js plugin for audio playback and usually stream files with:
// within index.html.erb
audio.load($('.track_info a', clicked_node).attr('data-src'));
audio.play();
When placed in a script block on any html page, it works perfectly. The problem I'm having involved attempting to call the audio plugin through a js callback. Nothing happens when I do the following:
// callback.js.erb
audio.load('<%= "#{@song.sample_url}" %>');
audio.play();
Even when I wrap that with:
$.getScript('/javascripts/audio.js', funct开发者_JS百科ion(){
alert("Successfully loaded audio.");
)};
Any ideas?
p.s. - The other jquery within callback.js.erb work properly.
Try this:
$.getScript('/javascripts/audio.js', function(){
audio.load('<%= @song.sample_url %>');
audio.play();
)};
精彩评论