Use javascript variables in Rails view helpers
- by Horacio
Using jqGrid I want to generate delete links for each row in the grid. The standard way to do this is to add the links in the gridComplete callback like shown below:
gridComplete: function() {
var ids = jQuery("#jobs_table").jqGrid('getDataIDs');
for(var i=0;i < ids.length;i++){
var cl = ids[i];
be = '<%= link_to(image_tag("delete.gif", :border=>0, :size=>"20x22", :alt => "delete"),·
{ :action => 'destroy', :id => 'cl', :method => :delete}, :class => 'ajax') -%>';
jQuery("#jobs_table").jqGrid('setRowData',ids[i],{workflow_state:be});
}
},
Using getDataIDs I get a list of IDs that I can use to generate the delete links. The problem is that this is a javascript call that results in a javascript variable.
The question is how can I use this variable "cl" inside rails link_to view helper?