This is my "link":
%span{:id => "car_#{car.id}", :onclick => "add_car(#{car.id}"} Add
that leads on to here:
function add_trending(car_id) {
jQuery.ajax({
url: "/cars/add_car",
type: "GET",
data: {"car_id" : car_id},
dataType: "html"
});
}
in controller:
def add_car
@car = Car.find(params[:car_id])
...
respond_to do |format|
format.js
end
end
and add_car.js.erb:
alert("YES");
But the alert window is not popped up. When I take a look at logs, I see there following:
Rendered cars/add_car.js.erb (0.0ms)
The javascript is just rendered, not executed based on logs. How is that possible?
Thanks