On Monday, July 29, 2013 5:03:13 PM UTC-5, Ruby-Forum.com User wrote:

> Hi All, 
>
> I'm making a Rails app in which users have folders in which to organize 
> journal entries. I'm trying to load a partial into view that displays 
> D3.js visualizations based on the character count of each journal entry. 
> The JavaScript code and HTML inject properly, but I don't think the JS 
> is executing. 
>
> Show.js.erb looks like this: 
> $("#actual-right").append( "<%=j render :partial => 'contents', :locals 
> => {:folder => @folder } %>" ); 
>
> $("#jscripts").append("<%=j render :partial => 'show', formats: :js, 
> :locals => {:folder => @folder} %>"); 
>
> The second line appends _show.js.erb with the rest of my JavaScript in 
> application.html.erb. The top line appends some HTML tags for D3. 
>
> I need to figure out how to execute the JavaScript so when a user clicks 
> the link to one of their folders, the HTML and JS are injected and the 
> graphs are drawn. Attached is my _show.js.erb file -- I have tried 
> wrapping all the D3 code in a function and calling it at the bottom, but 
> that didn't work. 
>
> Any advice would be appreciated! 
>
> Attachments: 
> http://www.ruby-forum.com/attachment/8638/_show.js.erb 


 You can try wrapping your javascript function calls in a jQuery 
document.ready call. It'll fire off when the document object model is 
ready. 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/bfc4a034-f05d-48b5-a0ba-0146e5bf6935%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to