Vote_fu和Ajax请求
我现在已经好几个小时了,试着投票和投票。 我终于对一个可投票的对象(专辑)进行了投票,但是我必须不断更新页面以查看我对使用rails的Ajax知识的影响是基本的,我不知道我在哪里出错这个任何帮助都会太棒了会非常感激!!!
相关代码如下:
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
Layout / appliction.html.erb(javascript添加到标题中)
查看/票
_album_vote.html.erb
user_album_votes_path(album.user, album, :vote => :true, :format => :rjs), :method => :post %> current_user.vote_down_path(album), :vote => :false, :format => :rjs, :url => user_album_votes_path(album.user, album, :vote => :false, :format => :rjs), :method => :post %> Votes:
| ___________________________________________________________________________________________
视图/专辑/显示:
<div id="votes_" class="album_votes"> "votes/album_vote", :locals => {:album => @album} %>