On does not work as a replacement for live ; since the new ON does NOT work for future items. No problem in my implementations; I'm used to living live, and I definitely know when something works or not with jquery.
haml part:
.field %label Select a file = file_field_tag 'post[image]', :class => :dashed %span.adder + add another file
coffe part:
$("span.adder").on "click", (e) -> new_field = $(this).closest(".field").clone() $(new_field).insertAfter( $(this).closest(".field") )
Why doesn't the newly added span.adder have jquery behavior associated with their class? Something like this shoudl works in this case.
Why did jQuery guys delete it? I do not understand.
UPDATE
$("span.adder").on("click", function(){ });
Will not work like a living.
It should be
$(document).on("click", "span.adder", function(){ });
(thanks for answers).
source share