I try to implement a little AJAX powered voting on a site. I checked, that the template includes the javascript libraries:
<%= javascript_include_tag :defaults %> and add a remote form to the template: <div id="voting<%= artist.id %>"> <%= render(:partial => "voting", :object => artist) %> </div> The partial template _voting.rhtml does exist: Votings: <%= voting.votes %> <% form_remote_tag :url => { :action => :vote, :id => voting } do %> <%= submit_tag "Vote" %> <% end %> In the controller I implemented the method to handle the request: def vote begin @artist = Artist.find(params[:id]) rescue ActiveRecord::RecordNotFound logger.error("Attempt to access invalid artist #{params[:id]}") else @artist.votes = @artist.votes + 1 @artist.save end end and there is an RJS template vote.rjs: page.replace_html("voting" + @artist.id.to_s, :partial => "voting", :object => @artist) When I call the page and press the vote button, the request is send to the server and the database was updated, but the website did not change. When I reload the page the correct new value will be displayed. I debugged this with FireBug in Firefox an I can see the ajax request thats been sent to the server and the following response to this request: try { Element.update("voting215", "Votings: 26\n<form action=\"/voting/vote/ 215\" method=\"post\" onsubmit =\"new Ajax.Request('/voting/vote/215', {asynchronous:true, evalScripts:true, parameters:Form.serialize (this)}); return false;\"> \n\t<input name=\"commit\" type=\"submit\" value=\"Vote\" /> \n</form>\n" ); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.update(\"voting215\", \"Votings : 26\\n<form action=\\\"/voting/vote/215\\\" method=\\\"post\\\" onsubmit=\\\"new Ajax.Request(\'/voting /vote/215\', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\ \\"> \\n\\t<input name=\\\"commit\\\" type=\\\"submit\\\" value=\\ \"Vote\\\" /> \\n</form>\\n\");'); throw e } Does anyone has an idea what I'm doing wrong? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---