javascript - Ruby on Rails - Passing data directly to jQuery -


i'm trying update or populate table on click passing variables.

for checkbox, have done following, works perfectly.

<td><%= check_box_tag item_counter, item.to_json, false,                           {:class => 'show', :onclick => "select.update(this)"}%></td> 

and jquery function is,

 $(function () {      select.init();   });  select = {    update: function (obj) {    //table update logic missing simplicity     console.log(obj);   } } 

now need creat link similar functionality check_box_tag, have done this,

<%= link_to item_count[:name],"#", {:onclick => "select.update(this)", :id => item_count_counter} %> 

how pass parameters jquery function in case?

i've seen using rails tag helpers work things similar describing. however, can little messy when want incorporate client side functionality it.

it might worth ditching <%= %> clarity - @ least.

but provided you're committed tag helper, have error messages js console can show? in first example - helper nested in <td>, still case in second example? using id: can cause issues other variables in scope in js.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -