I have one Controller VendorController. And view file is index.html.erb
I want to pass the id of vendor through onclick function. Here is my code
Codes under vendors_controller.rb
def index
@vendor = Vendor.all
end
Codes of index.html.erb
<script language="javascript" type="text/javascript">
function func1(id) {
alert(_id);
}
function func2(id) {
alert(id);
}
</script>
<% @vendors.each do |vendor| %>
<tr>
<td><%=link_to vendor.name , '#', onclick: "func1(1)", remote: true %></td>
<td><%= link_to vendor.id, '#', :onclick => 'func2(vendor.id)' %></td>
</tr>
<% end %>
For func1() i am getting the alert. But for func2 I am not getting any response.
Please help..thank you in advance.
_idinstead ofidin the first function.