2011-12-23 3 views
1

GiggleTrigger.com을 Rails 3.1로 업그레이드하고 있습니다. 이 사이트는 사용자가 펀치 라인 (오렌지색 플래시)에 투표 할 때 시원한 하이라이트 효과가 있습니다. 계정을 만들면 직접 시도 할 수 있습니다.Rails 3.1로 업그레이드되었지만 강조 효과가 작동하지 않습니다.

어쨌든 Rails 3.1로 업그레이드했을 때 강조 효과가 더 이상 작동하지 않습니다. (4 행의 투표 :에 punchline_id 변경) : I로 변경

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 

: 여기

(나는 사소한 아래에 언급되는 변화를 제작되는) 내 원래 VotesController입니다

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> 
나는 변경 될 때까지 투표를 작성하지 않은 ("웃음"이라고합니다)

page.replace_html "vote_total_#{@punchline.id}", "#{@punchline.votes.size}" 
page["vote_total_#{@punchline.id}"].effect :highlight, 
              :color => "#f7931e", 
              :endcolor => "#e6e6e6" 

투표 버튼 :

이 0 (create.js.rjs로보기/투표 파일에 배치) 아약스입니다 : punchline_id : 투표하십시오. 하지만 여전히 저에게 플래시 효과를주지는 않습니다. 내 생각에 어쨌든이 자바 스크립트를 자산 파이프 라인으로 가져와야 할 필요가있다. 모든 지침을 부탁드립니다. 감사.

답변

2

강조 표시는 Prototype 함수이고 Rails 3.1은 기본적으로 jQuery를 사용하기 때문에 가능합니다.

+0

오른쪽. 업그레이드했을 때 나는 Jrails를 제거했기 때문에. 사격. – thatdankent

+0

jQuery에서하는 방법에 대한 아이디어가 있으십니까? – Shobhit

+0

자신 만의 .highlight() fn을 사용하거나 jQueryUI의 강조 표시를 사용해야합니다. http://docs.jquery.com/UI/Effects/Highlight#option-color – grumpit

관련 문제