当我更改应用程序的内容状态时,数据库更新的背景工作正常。但该link_to :loading
操作不起作用。
查看:页面中元素的 _feedback_question_status.html.erb
<% if feedback_question.status == 1 %>
<span id="feedback_question">enabled -- <%= link_to "change", {:action=>"feedback_question_status",:status => 0,:feedback_question=>feedback_question.id}, :remote=>true, :loading => "$('#feedback_question_disable_#{feedback_question.id}').replaceWith('<p>Loading..</p>')", :update =>"feedback_question"%></span>
<% else %>
<span id="feedback_question">disabled -- <%= link_to "change",{:action=>"feedback_question_status",:status => 1, :feedback_question=>feedback_question.id }, :remote=>true, :loading => "$('#feedback_question_enable_#{feedback_question.id}').replaceWith('<p>Loading..</p>')", :update =>"feedback_question"%></span>
<% end %>
控制器:
有update_attributes
和render :partial=>'feedback_question_status'
在服务器上:
Started GET "feedback/feedback_question_status?feedback_question=6&status=1" for 127.0.0.1 at 2012-08-27 16:25:47 +0530
... Snippet
(0.2ms) BEGIN
...
(30.7ms) COMMIT
Rendered _feedback_question_status.html.erb (2.7ms)
最后一行显示部分已渲染。但意见没有变化。这意味着页面上的元素没有任何反应。
为feedback_question 搜索路由:
feedback_feedback_question_status /feedback/feedback_question_status(.:format) feedback#feedback_question_status
feedback_questions feedback/new_feedback_question(.:format) feedback#new_feedback_question
edit_feedback_question /feedback/:id/edit_feedback_question(.:format) feedback#edit_feedback_question
update_feedback_question /update_feedback_question/:id(.:format) feedback#update_feedback_question
feedback_question_status /feedback_question_status(.:format) feedback#feedback_question_status
刷新页面后显示更改。但我不想再次加载页面。