<% if @questions_counter == 2 %>
<% if @finish == 0 %>
$("#initial-question-frame").fadeOut('fast');
$("#next-question-frame").html("<%= escape_javascript(render(:partial => "question", :locals => {:question => @question, :finish_btn => @finish_btn })) %>").fadeIn();
<% else %>
$("#next-question-frame").html("<%= escape_javascript(render(:partial => "grade", :locals => {:correct_answers => @correct_answers, :grade => @grade, :total_questions => @total_questions })) %>").fadeIn();
<% end %>
<% else %>
<% if @finish == 0 %>
$("#next-question-frame").html("<%= escape_javascript(render(:partial => "question", :locals => {:question => @question, :finish_btn => @finish_btn })) %>").fadeIn();
<% else %>
$("#next-question-frame").html("<%= escape_javascript(render(:partial => "grade", :locals => {:correct_answers => @correct_answers, :grade => @grade, :total_questions => @total_questions })) %>").fadeIn();
<% end %>
<% end %>
$(document).ready(function(){
$(":checkbox").on('change',function() {
var that = this;
if (!$(this).parent().hasClass("remember-label")){
$(this).parent().css("background-color", function() {
return that.checked ? "#C0E9F7" : "";
});
}
});
$("input[type=radio]").on('change',function() {
$(this).parents().eq(1).siblings().css("backgroundColor","");
$(this).parents().eq(1).css("backgroundColor","#C0E9F7");
});
});
Under normal circumstances the javascript code if the page is reloaded properly it works. If its like this though it does not work. When i click on label which wraps the inputs and it has correct for attribute, nothing happens not even the checkbox/radio button gets checked.
<label for="choice_<%= choice.id %>">
<%= radio_button_tag("choice","#{choice.id}",false,class:"radio big-radio") %>
<% if choice.image? %>
<%= image_tag rewrite_url(choice.image_url(:resized)), class:"choice-image" %>
<% else %>
<%= choice.description %>
<% end %>
</label>