开发者

Why is my jquery not working in Rails 3 using js.erb

开发者 https://www.devze.com 2023-03-06 02:33 出处:网络
vote_up.js.erb: 1 $(\".total-vote-count\").val(\"#{@plusminus}\") 2 $(\"a.vote-up-off\").addClass(\"vote-up-on\")

vote_up.js.erb:

  1 $(".total-vote-count").val("#{@plusminus}")
  2 $("a.vote-up-off").addClass("vote-up-on")

My view:

 11     #voting
 12       #vote-count
 13         = link_to "Vote Up", {:controller => 'reviews', :action => 'vote_up', :id => @review.id},
 14                              {:class => "#{@vote_up_status}", :remote => tru开发者_如何学Pythone }
 15       
 16         %span.total-vote-count
 17           = @review.plusminus
 18 
 19         = link_to "Vote Down", {:controller => 'reviews', :action => 'vote_down', :id => @review.id},
 20                                {:class => "#{@vote_down_status}", :remote => true}

I know that the js.erb does render because when I do something on the entire vote-count div to replace it with text("what is up") it works. But what I have doesn't :(

Help?


Errr, I'm a noob, but in your js.erb, aren't you supposed to use <%= => ? Like $(".total-vote-count").val("<%= #{@plusminus} %>") ?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号