
[英]I have three dropdown and I want that when I select the value of first dropdown, that value should not appear in second dropdown
[英]I want to open dropdown when I select value from any other dropdown specifically in iPad/iPhone.
我想打開一個下拉菜單,更改事件發生在另一個下拉菜單上。 以下代碼段在瀏覽器上正常運行,但在混合應用程序中的iPhone / iPad上不起作用。
我們將不勝感激。請檢查jsfiddle上的代碼段
function ViewModel(choices, choice) { this.choices = ko.observableArray(); this.choice = ko.observable(); this.changedropDown=function(data,event){ console.log("inside changedropDown"); this.bindDropDown(event); }; this.bindDropDown= function(event){ //event.stopPropagation(); console.log("insdie bindDropDown"); this.choices(choices); setTimeout(function() { showDropDown("xyz"); }, 500); }; }; var showDropDown = function (id) { console.log("inside showDropDown"); var dropdown = document.getElementById(id); var event = document.createEvent('MouseEvents'); event.initMouseEvent('mousedown', true, true, window); dropdown.dispatchEvent(event); }; var choices = [{ id: 1, name: "one" }, { id: 2, name: "two" }, { id: 3, name: "three" }]; ko.applyBindings(new ViewModel(choices));
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script> <select name="cars" data-bind="event:{change:function(data,event){changedropDown(data,event)}}"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="fiat">Fiat</option> <option value="audi">Audi</option> </select> <select id="xyz" data-bind="options: choices, optionsText: 'name', value: choice"></select>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.