code_junkie

How do I update the contents of a placeholder with a generated image in Rails?

Nov 12th, 2011
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. send_data g.to_blob, :disposition=>'inline', :type=>'image/png', :filename=>'top_n.pdf'
  2.  
  3. :complete => "updateImg(id_of_div, request.responseText)"
  4.  
  5. function updateImg(id, img)
  6. {
  7. $(id).innerHTML = '<img src="' + img + '" />';
  8. }
  9.  
  10. def graph
  11. # get the relevant data for 'g' here
  12. respond_to do |format|
  13. format.html #uses the default view if relevant (good for debugging)
  14. format.png do
  15. send_data g.to_blob,
  16. :disposition=>'inline',
  17. :type=>'image/png',
  18. :filename=>'top_n.pdf'
  19. end
  20. end
  21. end
  22.  
  23. <img src="controller/graph.png" alt="Something"/>
Add Comment
Please, Sign In to add comment