I have this "Add Vehicle" button which renders and adds partial to view, and I will have it many times, so anonymous function won't work, so is there any way I can define function and parameters in link_to helper?
part from form where I'm calling js, and in which i need to define functions name and parameters
...
<div id="add_vehicle_div_button2">
<%= link_to 'Add vehicle', attach_vehicle_path, remote: true, id: "add_vehicle_button2" %>
</div>
<div id="attached_vehicle2" style="display:none;"></div>
...
../views/diys/attach_vehicle.js.erb to which it leads
function addAttachVehicleFields(newAttachVehicleDiv, addVehicleDivButton, attachVehiclePartial) {
$(newAttachVehicleDiv).html("<%= escape_javascript (render #{attachVehiclePartial}) %>");
$(newAttachVehicleDiv).slideDown(350);
$(addVehicleDivButton).css('display', 'none');
}
And from there it renders defined partial.
The reason why I have this function in its own file in views folder is that i need it to have its own controller action.