javascript - Rails: editing a form with checkboxes -


i have form list of checkbox entries. when edit entry form comes boxes checked, regardless of checked when form submitted.

how make 'remember' checks?

this controller's update action:

def update   @student = student.find(params[:id])   if @student.update_attributes!(params[:student])     flash[:success] = "student updated"     redirect_to @student   else     render 'edit'   end end 

this view:

<% c = [ 'characteristic_the_first', 'characteristic_the_second',      'characteristic_the_third', 'characteristic_the_fourth',      'characteristic_the_fifth', 'characteristic_the_sixth' ] %>  <% = 0 %>  <div> characteristics </div> <%= f.fields_for :characteristics, :wrapper => false |char| %>   <div>     <%= char.check_box :name, {class: "checkme"}, c[i], c[i] %>     <%= char.label :name, c[i], {class: "medium_font"} %>     <%= char.text_area :notes, {id: c[i], hidden: "true"} %>     <% i+=1 %>   </div> <% end %> 

checkboxes reveal hidden textboxes through jquery (though isn't relevant question):

$( document ).ready(function() {   $('.checkme').click(function(){     if($("#" + $(this).val()).attr('hidden')){       $("#" + $(this).val()).attr('hidden', false);     }else{       $("#" + $(this).val()).attr('hidden', true);     }   }); }); 


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -