diff --git a/jquery.dependent-selects.coffee b/jquery.dependent-selects.coffee index 9f06129..bc7b4bf 100644 --- a/jquery.dependent-selects.coffee +++ b/jquery.dependent-selects.coffee @@ -196,11 +196,10 @@ current_option_text = $selected_option.html() for i in [(parseInt $selected_select.attr('data-dependent-depth'))..0] + $(@).removeAttr('selected') $current_select.find('option').each -> if $(@).html() == current_option_text $(@).attr('selected', 'selected') - else - $(@).removeAttr('selected') showSelect $current_select current_option_text = $current_select.attr('data-dependent-parent') diff --git a/jquery.dependent-selects.js b/jquery.dependent-selects.js index 2412649..a212f33 100644 --- a/jquery.dependent-selects.js +++ b/jquery.dependent-selects.js @@ -225,11 +225,10 @@ $current_select = $selected_select; current_option_text = $selected_option.html(); for (i = _i = _ref = parseInt($selected_select.attr('data-dependent-depth')); _ref <= 0 ? _i <= 0 : _i >= 0; i = _ref <= 0 ? ++_i : --_i) { + $(this).removeAttr('selected'); $current_select.find('option').each(function() { if ($(this).html() === current_option_text) { return $(this).attr('selected', 'selected'); - } else { - return $(this).removeAttr('selected'); } }); showSelect($current_select);