I was trying to add javascript variable in link_to. but name appear as "+item_id+" not as a variable. my code is below.
var item_id = item[0]
$('#item').append('<%= link_to '+ item_id +' , prd_item_path('+ item_id+') %>')
I was trying to add javascript variable in link_to. but name appear as "+item_id+" not as a variable. my code is below.
var item_id = item[0]
$('#item').append('<%= link_to '+ item_id +' , prd_item_path('+ item_id+') %>')
You're mixing server side with client side code. Keeping in mind that the link_to helper is rendered as a "normal" anchor tag, and that you can't mix the ERB code passing JS values, then you can use that anchor, and concatenate the JS values.
Try with:
$('#item').append('<a href="item/' + item_id + '">' + item_id + '</a>')
Being item/
the URI of prd_item_path
.