From: Tara L Andrews Date: Fri, 8 Jun 2012 10:35:42 +0000 (+0200) Subject: make checkbox persistence work properly X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=798fa9390353a5d155f678dcf359353dbd15cc1a;p=scpubgit%2Fstemmaweb.git make checkbox persistence work properly --- diff --git a/root/js/relationship.js b/root/js/relationship.js index 3fa40d1..ed43d5d 100644 --- a/root/js/relationship.js +++ b/root/js/relationship.js @@ -52,8 +52,8 @@ function node_dblclick_listener( evt ) { // Set the easy properties first $('#reading-form').dialog( 'option', 'title', 'Reading information for "' + reading_info['text'] + '"' ); $('#reading_id').val( reading_id ); - $('#reading_is_nonsense').attr( 'checked', reading_info['is_nonsense'] ); - $('#reading_grammar_invalid').attr( 'checked', reading_info['grammar_invalid'] ); + toggle_checkbox( $('#reading_is_nonsense'), reading_info['is_nonsense'] ); + toggle_checkbox( $('#reading_grammar_invalid'), reading_info['grammar_invalid'] ); // Use .text as a backup for .normal_form var normal_form = reading_info['normal_form']; if( !normal_form ) { @@ -71,6 +71,13 @@ function node_dblclick_listener( evt ) { $('#reading-form').dialog("open"); } +function toggle_checkbox( box, value ) { + if( value == null ) { + value = false; + } + box.attr('checked', value ); +} + function morphology_form ( lexlist ) { $('#morphology').empty(); $.each( lexlist, function( idx, lex ) {