2013-04-29 51 views
0

我確信這很簡單,但我會很感激任何幫助。ajax調用後不加載對象

我有什麼是顯示問題和答案的頁面。

我的模型建立,這樣的問題(這實際上是一個名爲調查)窩我想提交後以遞增到下一個問題的答案

我所做的是創建了一個調用形式一個JavaScript(AJAX回調更新控制器),一切運作良好,但當我嘗試渲染的部分它不顯示,我從控制檯沒有錯誤我的update.js.erb是我想渲染

$('#questionarea ul').show().load("<%= escape_javascript render :partial => "current_question" %> "); 

部分_current_question.html.erb很簡單, <%= @current_question%>

我一直在使用Chrome瀏覽器客戶端來調試,但我沒有得到任何錯誤,並在控制檯顯示正常執行 任何及所有的幫助表示讚賞 我也加入,以供參考HTML還有JavaScript的被稱爲阿賈克斯以及 _form.html.erb

<%= form_for @category, remote: true do |f| %> 

<ul id= 'questionarea'> 
<%[email protected] %> 
</ul> 
<ul> 
     <%=hidden_field_tag(:survey_id, @category.surveys.first.survey_id) %> 
     <%=hidden_field_tag(:user_id, params[:id]) %> 
</ul> 
<ul id= 'answerarea'> 
    <%= radio_button_tag(:agree , 5) %> 
    <%= label_tag(:agree_5, "I completely agree ") %> 
    <%= radio_button_tag(:agree , 4) %> 
    <%= label_tag(:agree_4, "I agree ") %> 
    <%= radio_button_tag(:agree , 3) %> 
    <%= label_tag(:agree_3, "I kind of agree ") %> 
    <%= radio_button_tag(:agree , 2) %> 
    <%= label_tag(:agree_2, "I disagree ") %> 
    <%= radio_button_tag(:agree , 1) %> 
    <%= label_tag(:agree_1, "I completly disagree ") %> 

     This statement is: 

    <%= radio_button_tag(:importance , 3) %> 
    <%= label_tag(:importance_3, "Incredibly important ") %> 
    <%= radio_button_tag(:importance , 2) %> 
    <%= label_tag(:importance_2, "Kind of important") %> 
    <%= radio_button_tag(:importance , 3) %> 
    <%= label_tag(:importance_1, "A good thing to trade for something I care about ") %> 
</ul> 
<ul> 
    <li>Comments:</li> 
     <li><%= text_field_tag :comments %></li> 
</ul> 

<ul> 
<%= f.submit %> 

我的JavaScript(form.js)

$('.edit_category input[type=submit]').click(function() { 
$(this).parent('form').submit(); 
}); 

在此先感謝

+0

** $('#questionarea ul')**似乎沒有指向任何東西,**#questionarea **中沒有** ul **標籤,我想你的意思是** $('#questionarea') ** – Raindal 2013-04-29 18:56:15

+0

謝謝你是真的很欣賞我喜歡這個網站的快速反應! – Jan 2013-04-29 19:11:57

+0

我發佈了回覆,因此很明顯這是解決方案。順便說一下,歡迎您:) – Raindal 2013-04-29 19:15:01

回答

0

$( '#questionarea UL')似乎是指向什麼都沒有,沒有UL標籤在你#questionarea,我認爲你的意思$( '#questionarea')