From 02ca9bde32e6bd71a261a88ad8f763f0379509d6 Mon Sep 17 00:00:00 2001 From: Victor Demin Date: Mon, 30 Mar 2015 12:22:53 +0300 Subject: [PATCH] fix bug with not selected option in chrome --- jquery.dependent-selects.coffee | 3 +-- jquery.dependent-selects.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) 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);