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