Better coordination between 'null' checkbox and corresponding select/editor.

This commit is contained in:
Madhura Jayaratne
2011-02-21 01:15:40 +05:30
parent f6285413d7
commit c3501a3839

View File

@@ -452,24 +452,36 @@ $(document).ready(function() {
// if the select/editor is changed un-check the 'checkbox_null_<field_name>'. // if the select/editor is changed un-check the 'checkbox_null_<field_name>'.
if ($this_field.is('.enum, .set')) { if ($this_field.is('.enum, .set')) {
var $editor = $this_field.find('select'); $this_field.find('select').live('change', function(e) {
$('.checkbox_null_' + field_name).attr('checked', false);
})
} else if ($this_field.is('.relation')) { } else if ($this_field.is('.relation')) {
var $editor = $this_field.find('select'); $this_field.find('select').live('change', function(e) {
$('.checkbox_null_' + field_name).attr('checked', false);
})
$this_field.find('.browse_foreign').live('click', function(e) {
$('.checkbox_null_' + field_name).attr('checked', false);
})
} else { } else {
var $editor = $this_field.find('textarea'); $this_field.find('textarea').live('keypress', function(e) {
$('.checkbox_null_' + field_name).attr('checked', false);
})
} }
$editor.live('change', function(e) {
$('.checkbox_null_' + field_name).attr('checked', false);
})
// if 'chechbox_null_<field_name>' is clicked empty the select/editor. // if 'chechbox_null_<field_name>' is clicked empty the select/editor.
$('.checkbox_null_' + field_name).bind('click', function(e) { $('.checkbox_null_' + field_name).bind('click', function(e) {
if ($this_field.is('.enum, .set')) { if ($this_field.is('.enum, .set')) {
$this_field.find('select').selectedIndex = -1; $this_field.find('select').selectedIndex = -1;
} else if ($this_field.is('.relation')) { } else if ($this_field.is('.relation')) {
$this_field.find('select').attr('value', ''); // if the dropdown is there to select the foreign value
if ($this_field.find('select').length > 0) {
$this_field.find('select').attr('value', '');
// if foriegn value is selected by browsing foreing values
} else {
$this_field.find('span.curr_value').empty();
}
} else { } else {
$this_field.find('textarea').empty(); $this_field.find('textarea').val('');
} }
}) })