我已經在現在幾個小時,試圖得到vote_fu和運行。我終於對一個可投票的對象(專輯)進行了投票,但我必須不斷刷新頁面才能看到我的Ajax知識對軌道的影響是基本的,我不知道我會在哪裏出錯,非常感謝!Vote_fu和阿賈克斯請求
相關的代碼如下:
JavaScript文件
application.js:
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
jQuery.ajaxSetup({
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
})
jQuery(document).ready(function() {
$("#votes_ .album").bind('click', function(e)
});
| ___________________________________________________________________________________________
的jquery.js jQuery的ui.js jrails.js
佈局/機應用.html.erb(javascript添加到標題)
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag 'jquery.js', 'application.js' %>
視圖/票
_album_vote.html.erb
<%#
# You can't vote if it is your quote,
# you are not logged in,
# or you have already voted on this item
unless album.user == current_user ||
current_user.voted_on?(@album)
%>
<%= link_to_remote "Vote Up",
:url => user_album_votes_path(album.user, album, :vote => :true, :format => :rjs),
:method => :post %>
<%= link_to_remote "Down",
#:url => current_user.vote_down_path(album), :vote => :false, :format => :rjs,
:url => user_album_votes_path(album.user, album, :vote => :false, :format => :rjs),
:method => :post
%>
<%# end %>
Votes: <%= @album.votes_for - @album.votes_against %>
| ___________________________________________________________________________________________
視圖/專輯/顯示:
<div id="votes_<%= @album.id %>" class="album_votes">
<%= render :partial => "votes/album_vote", :locals => {:album => @album} %>
</div>
| ___________________________________________________________________________________________
create.rjs
page.replace_html "votes_#{@album.id}", :partial => "album_vote", :locals => {:album => @album}
| ___________________________________________________________________________________________
error.rjs
| ___________________________________________________________________________________________
我試着玩ID #votes_。album,我認爲它的名稱不正確,但仍然無法正常工作,甚至沒有出現錯誤,就好像javascript已關閉!
任何幫助將是偉大的!
發現錯誤的服務器控制檯上:
NameError (uninitialized constant Mime::RJS):
app/controllers/votes_controller.rb:54:in `create'
app/controllers/votes_controller.rb:52:in `create'
我將前熄燈(睡覺時間)同意這個!
如果你喜歡幫我一把!
問候
丹
在螢火蟲的幫助下再次查看這個問題的問題是與application.js 1錯誤不知道如何解決,但仍然期待它! – MrThomas 2010-03-04 15:56:29