i trying render partial on page there no errors in console or in terminal log scenario ... user selects link on page , middle area should render. running thru jquery , letting submit go controller 'session' , method 'showsurvey' gets information necessary , renders showsurvey.js.erb replace html showsurvey partial
here code involved ....shownewuser.html.erb
<%= include_gon %> <div id="content" class="clearfix"> <%= render :partial => 'layouts/user_profile' %> <div class="inner"> <div class="top_area"> </div> <!-- top_area --> <p>welcome <%=@user.email%> drag topics order of importance you.</p> <div id="middle_area" > <%= render :partial => 'middle_newuser' %> <div id="find"> <p>where voters , politicians can discuss , learn issues free no advertising dollars getting in way <br /> subscribe rss feeds stay in touch latest votes. </p> </div> </div> <!-- inner_area -->
the orginal partial replace _middle_newuser.html.erb
<div id = "draggable" class="ui-widget-content"> <h3 class="ui-widget-header">issues</h3> <table> <tr><td> <ul id ="column1" > <% (0..5).each |i| %> <% @sm_pic= @cat[i][:small_pic] @catname = @cat[i][:name] @id = @cat[i][:id]%> <li id="draggable"> <%= link_to image_tag(@sm_pic, :border => 0), showsurvey_path({:data => @id}), :remote => true, :data => @id , :id => 'showsurvey' %> </li> <% end %> </ul> </td> <td> <ul id ="column1" > <% (6..11).each |i| %> <% @sm_pic= @cat[i][:small_pic] @catname = @cat[i][:name] @id = @cat[i][:id]%> <li id="draggable"> <%= link_to image_tag(@sm_pic, :border => 0), showsurvey_path, :data => @id %> </li> <% end %> </ul> </td> <td> <ul id ="column1" > <% (12..17).each |i| %> <% @sm_pic= @cat[i][:small_pic] @catname = @cat[i][:name] @id = @cat[i][:id]%> <li id="draggable"> <%= link_to image_tag(@sm_pic, :border => 0), showsurvey_path, :data => @id %> </li> <% end %> </ul> </td></tr> </table> </div id> <!-- draggable --> </div> <!-- middle_area --> and partial should replace ...._middle_survey.html.erb
<div> <table><tr> <div id="middle_area-left" > <p>welcome survey page user after clicking on priority icon.</p> </div> <div id="middle_area-center" > <%= render :partial => 'form' %> </div> <div id="middle_area-right" > <p>welcome survey page user after clicking on priority icon.</p> </div> </tr> </table> </div> the controller method showsurvey
def showsurvey @title = "survey for" @category = category.find(params[:data]) @questions = @category.questions.find_all_by_category_id(params[:data]) @current_question_rec = @questions.first @current_question = @current_question_rec.question @current_question_id = @current_question_rec.question_id @answer = @category.questions.find(@current_question_id).answers.find_by_user_id(params[:id]) respond_to |format| format.html { redirect_to @category } format.js { render } end end
last showsurvey.js.erb
$(#middle_area').replace_html( "<%= escape_javascript render :partial => "middle_survey" %> "); one more thing here's output terminal
processing sessionscontroller#showsurvey js parameters: {"id"=>"3", "data"=>"3"} category load (0.2ms) select "categories".* "categories" "categories"."id" = ? limit 1 [["id", "3"]] question load (0.4ms) select "questions".* "questions" "questions"."category_id" = 3 , "questions"."category_id" = '3' question load (0.3ms) select "questions".* "questions" "questions"."category_id" = 3 , "questions"."question_id" = ? limit 1 [["question_id", 1]] answer load (0.3ms) select "answers".* "answers" "answers"."question_id" = 1 , "answers"."user_id" = 3 limit 1 rendered sessions/_form.html.erb (4.1ms) rendered sessions/_middle_survey.html.erb (5.8ms) rendered sessions/showsurvey.html.erb (7.6ms) completed 200 ok in 26ms (views: 13.9ms | activerecord: 1.1ms) thanks assistance
$(#middle_area').replace_html( "<%= escape_javascript render :partial => "middle_survey" %> "); looks typo, forgot forward quotes.
$('#middle_area')
also, i'm not @ css, can't see div #middle_area itself, sure jquery can parse #middle_area-right , on?
Comments
Post a Comment