title: Pass JSON object to onclick function
body: <p>I am trying to pass JSON object to onclick function but it does not work.</p>
  
  <pre><code>$.each(matches, function() {                        
      var item_data = { 
          "category" : this['category_name'],
          "stock" : this['stock_name'],
          "supplier_stock" : this['supplier_stock_name']
      };
  
      available_stock_items = available_stock_items + '&lt;tr&gt; \
          &lt;td&gt;' + this['category_name'] + '&lt;/td&gt; \
          &lt;td&gt;' + this['stock_name'] + '&lt;/td&gt; \
          &lt;td&gt;' + this['supplier_stock_name'] + '&lt;/td&gt; \
          &lt;td align="center"&gt;&lt;img src="' + $j('#edit-vardru-base-path').val() + 'sites/all/modules/core/images/add.png" onClick="select_item('+ item_data +');" /&gt;&lt;/td&gt; \
          &lt;/tr&gt;';
  });
  
  function select_item(data)
  {
      console.log("***********PRINT***************");
      console.log(data);
  }
  </code></pre>
  
  <p>I get this error "Uncaught SyntaxError: Unexpected identifier" in console window.</p>
  
  <p>EDIT:
  Now I am trying to pass data (<code>item_data</code>) using event delegation. I have added following code inside $.each(). Callback function is called at click event but I am not able to access item_data. </p>
  
  <pre><code>$j(document).delegate("#row-"+count, "click", function(item_data){
                          alert("TEST");
                          console.log("TEST");                            
                          console.log(item_data);     
                      });
  </code></pre>