Well, I know that's a common question and found a lot of advice how to do it but it doesn't work for me and I can't understand what's the matter.
index.html.slim
- books.each do |book|
.row class = "review_form" id = book.id
.panel
== render 'reviews/form', review: review, book: book
book.js.coffee
$('.row.review_form').hide()
$('#new_review_button').on "click", ->
$('.row.review_form#<%= book.id %>').show()
$('#new_review_button').hide()
$('#cancel_review').on "click", ->
$(".row.review_form#<%= book.id %>").hide()
$('#new_review_button').show()
According to instructions if you want to use ruby code in javascript you should use <%= ruby code %> as i'm doing here $('.row.review_form#<%= book.id %>').show() but nothing happens. It seems like when i write <%= in brackets it changes into one string and js doesn't understand it's a selector with ruby code. What am I doing wrong? Please, help, I'm totally confused! ><
Aucun commentaire:
Enregistrer un commentaire