Following Railscasts #197, would anyone know how to add a class to the link_to that's calling a js function?
<%= link_to_add_fields "Add Recipient", f, :recipients %>
_
function add_fields(link, association, content) {
var new_id = new Date().getTime();
var regexp = new RegExp("new_" + association, "g");
$(link).parent().before(content.replace(regexp, new_id));
}
I've tried a lot of different things but haven't found anything that worked. Like, I assume it should be something like:
<%= link_to_add_fields "Add Recipient", {f, :recipients}, :class => "button_add" %>
which would produce (with or without brackets around the two object being passed to the function:
undefined method `object' for #<Hash:0xaa8c320>
Ruby 1.8.7 / Rails 2.3.5