PeterStaev / NativeScript-Drop-Down

A NativeScript DropDown widget.
Apache License 2.0
105 stars 65 forks source link

Issue with 2 dropdowns on the same screen #61

Closed randy-johnson closed 7 years ago

randy-johnson commented 7 years ago

Hello,

I am working on a view that has 2 dropdowns on it. When a value is selected on 1 dropdown it is changing the value on the other dropdown.

I cannot seem to figure out what I need to change to stop this from happening.

Here is the sample code:

<dd:DropDown items="{{ gender }}" selectedIndex="{{ selectedIndex }}" opened="dropDownOpened" selectedIndexChanged="dropDownSelectedIndexChanged" hint="What is your Gender?" id="gender" /> <dd:DropDown items="{{ age }}" selectedIndex="{{ selectedIndex }}" opened="dropDownOpened" selectedIndexChanged="dropDownSelectedIndexChanged" hint="What is your Age?" id="age" />

and the javascript inside my loading function

var age = new observableArray.ObservableArray("18-20", "21-30", "31-40", "41-50", "51-60", "61-70", "71-80", "81-90", "91-100"); var gender = new observableArray.ObservableArray("Male", "Female", "Prefer Not to Say"); viewModel.set("age", age); viewModel.set("gender", gender); page.bindingContext = viewModel;

Thank you for your help.

Randy

PeterStaev commented 7 years ago

Hey @randy-johnson , the problem is that both your drop downs are bound to the same selectedIndex model variable.

randy-johnson commented 7 years ago

Yep that was it. Totally missed that. Thanks for your prompt reply.