New to using jQuery in Rails and can't get a div to be recognized for click or hover event. Using coffeescript as well, but compile looks fine. The divs all look good in the elements window in Chrome dev tools, but I don't get my console.log in the console window.
portion of my _form.html.haml
.field
= f.label :question
= f.text_field :question
%p Click the plus sign to add answers.
.field#answerone
= f.label :answers
= f.text_field :answers
#plusanswer
= image_tag("plusWhite.png", :alt => "plus sign")
.actions
= f.submit 'Save'
coffeescript:
$("#plusanswer").click ->
console.log("here we are")
$("#answerone").clone().appendto()
compiled javascript:
(function() {
$("#plusanswer").click(function() {
console.log("here we are");
return $("#answerone").clone().appendto();
});
}).call(this);
Is the way I'm doing the image_tag messing things up?
$(document).ready()handler? When I was starting out with CoffeeScript the difference between languages made me forgot to use that as well.appendto? jQuery hasappendTobut that wants an argument. And you do know that you'll be producing invalid HTML right? You can't have duplicateids in your HTML.