1
我正在將GiggleTrigger.com升級到Rails 3.1。當用戶投票時,該網站有一個很酷的突出效果(橙色閃光) - 如果你創建一個帳戶,你可以自己嘗試。升級到Rails 3.1,現在我的突出效果不起作用
無論如何,當我升級到Rails 3.1時,高光效果不再有效。
這是我原來的VotesController(而我做了一個微小的變化,這將在下文說明):
class VotesController < ApplicationController
def create
@punchline = Punchline.find(params[:punchline_id])
@vote = @punchline.votes.build params[:punchline_id]
@vote.user = current_user
respond_to do |format|
if @vote.save
format.js
format.html { redirect_to @punchline }
else
format.html { redirect_to root }
end
end
end
其中我變爲(改變:punchline_id到:在第4行投票):
class VotesController < ApplicationController
def create
@punchline = Punchline.find(params[:punchline_id])
@vote = @punchline.votes.build params[:vote]
@vote.user = current_user
respond_to do |format|
if @vote.save
format.js
format.html { redirect_to @punchline }
else
format.html { redirect_to root }
end
end
end
的看法是這樣的:
<span id="vote_total_<%= punchline.id %>" class="punchline_votes">
<%= punchline.votes.size %>
</span>
<span id="vote_button">
<%= button_to 'giggle', punchline_votes_path(:punchline_id => punchline),
:remote => true %>
</span>
這是阿賈克斯(放在意見/票文件create.js.rjs):
page.replace_html "vote_total_#{@punchline.id}", "#{@punchline.votes.size}"
page["vote_total_#{@punchline.id}"].effect :highlight,
:color => "#f7931e",
:endcolor => "#e6e6e6"
投票按鈕(稱爲「咯咯」),直到我換不創建一個投票: punchline_id到:投票。但它仍然沒有給我閃光效果。我的想法是,也許我需要以某種方式將這個JavaScript到資產管道。任何指導將不勝感激。謝謝。
對。因爲當我升級時,我淘汰了Jrails。射擊。 – thatdankent 2011-12-23 21:56:10
關於如何在jQuery中完成任何想法? – Shobhit 2012-08-04 11:13:17
你必須推出你自己的.highlight()fn或使用jQueryUI的亮點:http://docs.jquery.com/UI/Effects/Highlight#option-color – grumpit 2012-08-07 00:47:55