diff --git a/plugin/src/main/java/com/arcbees/chosen/client/ChosenImpl.java b/plugin/src/main/java/com/arcbees/chosen/client/ChosenImpl.java index 6cce6de..bda72bb 100644 --- a/plugin/src/main/java/com/arcbees/chosen/client/ChosenImpl.java +++ b/plugin/src/main/java/com/arcbees/chosen/client/ChosenImpl.java @@ -87,13 +87,13 @@ public abstract class ChosenImpl { protected boolean resultsShowing; protected GQuery searchChoices; protected GQuery searchContainer; + protected String defaultText; private GQuery $selectElement; private boolean allowSingleDeselect; private GQuery container; private String containerId; private ChosenCss css; private List selectedValues = new ArrayList(); - private String defaultText; private GQuery dropdown; private EventBus eventBus; private int fWidth; diff --git a/plugin/src/main/java/com/arcbees/chosen/client/DesktopMultipleChosenImpl.java b/plugin/src/main/java/com/arcbees/chosen/client/DesktopMultipleChosenImpl.java index 6d8eb26..fc6113d 100644 --- a/plugin/src/main/java/com/arcbees/chosen/client/DesktopMultipleChosenImpl.java +++ b/plugin/src/main/java/com/arcbees/chosen/client/DesktopMultipleChosenImpl.java @@ -84,6 +84,7 @@ protected StringBuilder buildOptionStyleClass(OptionItem option) { return classes; } + @Override protected void addChoice(OptionItem option) { if (maxSelectedOptionsReached()) { fireEvent(new MaxSelectedEvent(this)); diff --git a/plugin/src/main/java/com/arcbees/chosen/client/MobileMultipleChosenImpl.java b/plugin/src/main/java/com/arcbees/chosen/client/MobileMultipleChosenImpl.java index c9a0aa6..9c2b617 100644 --- a/plugin/src/main/java/com/arcbees/chosen/client/MobileMultipleChosenImpl.java +++ b/plugin/src/main/java/com/arcbees/chosen/client/MobileMultipleChosenImpl.java @@ -19,8 +19,10 @@ import com.arcbees.chosen.client.SelectParser.OptionItem; import com.arcbees.chosen.client.event.MaxSelectedEvent; import com.google.gwt.dom.client.OptionElement; +import com.google.gwt.dom.client.SelectElement; import com.google.gwt.query.client.GQuery; import com.google.gwt.user.client.Event; +import com.google.web.bindery.event.shared.EventBus; public class MobileMultipleChosenImpl extends AbstractMobileChosenImpl { @Override @@ -48,6 +50,7 @@ protected void addChoice(OptionItem item) { } } + @Override protected void resultDeactivate(GQuery query, boolean selected) { if (!selected) { super.resultDeactivate(query, selected); @@ -87,6 +90,13 @@ protected void update() { closeField(); } + @Override + protected void init(SelectElement element, ChosenOptions options, EventBus eventBus) { + super.init(element, options, eventBus); + + updateSelectedText(); + } + private void resultDeselect(OptionItem item, GQuery element) { choices--; @@ -111,8 +121,10 @@ private void updateSelectedText() { String selectedText; if (choices > 1) { selectedText = getOptions().getManySelectedTextMultipleMobile(); - } else { + } else if (choices == 1) { selectedText = getOptions().getOneSelectedTextMultipleMobile(); + } else { + selectedText = defaultText; } selectedText = selectedText.replace("{}", "" + choices);