From b86b5ced8651b29060be941451ae93d3c4261a7b Mon Sep 17 00:00:00 2001 From: jlukic Date: Fri, 23 Jan 2015 17:10:03 -0500 Subject: [PATCH] Dropdown clear now removes selected value --- RELEASE-NOTES.md | 2 +- src/definitions/modules/dropdown.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index f6b0eaf9a..1461f55ad 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -5,7 +5,7 @@ **Key Features** - **Form** - Form now has new methods `reset`, `clear`, `set value(s)`, and `read value(s)` for modifying and reading form data. Check docs for details on implementation. **Thanks @mktm** -- **Search** - Search `onSelect` now recieves JSON object matching currently selected element, you can now programmatically retrieve result JSON using `.search('get result', 'query')` or `.search('get results'). `get result` will default to current value unless specified as first parameter. +- **Search** - Search `onSelect` now recieves JSON object matching currently selected element, you can now programmatically retrieve result JSON using `.search('get result', 'query')` or `.search('get results')`. `get result` will default to current value unless specified as first parameter. - **Transition** - Added many new transitions, and new directions for existing transitions **Thanks @ph7vc** - **Dropdown** - Dropdown now stores `placeholder text` (prompt text) as separate from `default text` (text set on page load). You can now reset placeholder conditions using `$('.ui.dropdown').dropdown('clear');`` diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index ceb4126b7..05a5e205c 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -831,7 +831,7 @@ $.fn.dropdown = function(parameters) { } }, choiceValue: function($choice, choiceText) { - choiceText = choiceText || module.get.choiceText($text); + choiceText = choiceText || module.get.choiceText($choice); return ($choice.data(metadata.value) !== undefined) ? $choice.data(metadata.value) : (typeof choiceText === 'string') @@ -1009,6 +1009,8 @@ $.fn.dropdown = function(parameters) { ; module.set.text(placeholderText); module.set.value(''); + module.remove.activeItem(); + module.remove.selectedItem(); $text.addClass(className.placeholder); }, @@ -1151,7 +1153,7 @@ $.fn.dropdown = function(parameters) { .addClass(className.selected) ; selectedText = module.get.choiceText($selectedItem); - selectedValue = module.get.choiceValue($selectedItem); + selectedValue = module.get.choiceValue($selectedItem, selectedText); module.set.text(selectedText); module.set.value(selectedValue); settings.onChange.call(element, value, selectedText, $selectedItem);