Ruby on Rails
Thursday, April 4, 2013
hi i have a problem in graphs:
am representing data in graphical view and in that i put from date, end date and search button
when i select from date, end date and when i press search, values are going into controller through ajax and rendering partial but i can't able to pass the instance variable in partial view. i have tried the following
in the controller:
def abc
@x1 = Model1.all
@y1 = Model2.all
render :partial => "partial_name", :@x1 => @x1, :@y1 => @y1
render :partial => "filter_data", :locals => { :@x1=> @x1, :@y1 => @y1 }
end
in the partial view:
<div id="line-example" style="width: 1000px; height: 350px; margin-top: 50px; margin-left: 100px;"></div>
<script>
window.onload = function () {
Morris.Line({
element: 'line-example',
data: [ <% for j in 0...@y1.length %>
{y: '<%= @y1[j]%>', a: '<%= @x1[j] %>'},
<% end %>],
xkey: 'y',
ykeys: ['a'],
labels: ['Series A']
});
};
</script>
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/msg/rubyonrails-talk/-/C0GB8xoBGogJ.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment