autosaving checkboxes test zone

of Activity
Date of
Total Hours
of Activity
My Supervisor's Recommendation
This Activity Based On:
(Check Appropriate Column(s))
This Activity was part
of my development
plan for the year?
auto_save = ($form) -> # Save the form data to localStorage. $form.find(':input').on 'blur', (e) -> form_data = $form.serializeArray() # Get the radio buttons and checkboxes. checkboxes = $form.find(':input').filter(':checkbox').serializeArray() radios = $form.find(':input').filter(':radio').serializeArray() form_data = $.merge(form_data, checkboxes) form_data = $.merge(form_data, radios) localStorage.setItem($form.attr('id'), JSON.stringify(form_data)) restore_save = ($form) -> # Restore Form data if there is some in localStorage. form_data = localStorage.getItem($form.attr('id')) if form_data? form_data = JSON.parse(form_data) # Have to loop the data twice to add dynamic rows then fill them in. for obj in form_data if == '_rc]' # Find the add row button. obj_name ='[')['[').length - 1] add_button_id = obj_name.substring(0, obj_name.length - 4) + "-add" $add_button = $('#' + add_button_id) # Click it the appropriate number of times. for i in [0...parseInt(obj.value)] by 1 $add_button.trigger('click') # Fill in the fields. for obj in form_data $input = $("[name='#{}']") # Check for radio and checkboxes. if $':radio') and $input.val() == obj.value $input.attr('checked', true) if $':checkbox') if obj.value == 'on' $input.attr('checked', true) $input.val(obj.value) $('.add-row').on 'click', (e) -> e.preventDefault() table_body = $( if table_body add_row(table_body) add_row = (table_body_element) -> # Get some variables for the tbody and the row to clone. $tbody = $('#' + table_body_element) $rows = $($tbody.children('tr')) $cloner = $rows.eq(0) count = $rows.length # Update the _rc field. $('#items_rc').val(count) # Clone the row and get an array of the inputs. $new_row = $cloner.clone() inputs = $new_row.find('.dyn-input') # Change the name and id for each input. $.each(inputs, (i, v) -> $input = $(v) # Find the label for input and adjust it. $label = $new_row.find("label[for='#{$input.attr('id')}']") $label.attr( {'for': $input.attr('id').replace(/\[.*\]/, "[#{count + 1}]")} ) $input.attr({ 'name': $input.attr('name').replace(/\[.*\]/, "[#{count + 1}]"), 'id': $input.attr('id').replace(/\[.*\]/, "[#{count + 1}]") }) # Remove values and checks. $input.val('') checked = $input.prop('checked') if checked $input.prop('checked', false) ) # Add the new row to the tbody. $tbody.append($new_row) auto_save($('.new_input')) $form = $('.new_input') auto_save($form) restore_save($form)


Sorry for this second pop-up, but would it be helpful if we stored your purchase for you? (1st week free, then 29.99/ week)