Ruby on Rails Monday, July 29, 2013

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


--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1c7e5416b8beb12e5ae21b0781b4eaa1%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment