在webview中选择元素不起作用

时间:2018-01-31 05:09:37

标签: javascript android jquery webview

我在listview中创建了一个包含输入字段和select元素的模态。此列表显示在android的webview中。当我单击输入字段时,我可以更改其中的值,但是当我单击选择字段时,即使我在选择列表中有数据,也没有任何反应,甚至它都是由点击监听器聚焦的。有人可以帮我吗?

我正在分享示例代码: -

var modalInList = function(){
        var originalList = document.getElementsByClassName("tt-menu");
        var divElement = document.createElement("div")
        divElement.id = "divToAdd";
        var listElement = document.createElement("li");
        listElement.id = "listToAdd";
        var inputFieldForDose = document.createElement("input");
        var inputFieldForFrequency = document.createElement("select");
        var inputFieldForDays = document.createElement("input");
        var take = document.createElement("span");
        var tablet = document.createElement("span");
        var forData = document.createElement("span");
        var days = document.createElement("span");
        take.innerHTML = "Take"
        tablet.innerHTML = "Tablet"
        forData.innerHTML = "for"
        days.innerHTML = "Days"
        divElement.appendChild(take);
        inputFieldForDose.id = "doseList";
        inputFieldForFrequency.id = "frequencyList";
        inputFieldForDays.id = "daysList";
        inputFieldForDose.contentEditable = 'true'
        inputFieldForFrequency.contentEditable = 'true'
        inputFieldForDays.contentEditable = 'true'
        inputFieldForDose.style.color = "black";
        inputFieldForDose.style.width = "45px";
        inputFieldForDose.style.marginLeft = "1px";
        inputFieldForDose.style.marginRight = "1px";
        inputFieldForDose.style.textAlign = "center";
        inputFieldForDose.style.padding = "1px";
        inputFieldForDose.style.border = "solid 1px #c9c9c9";

        inputFieldForFrequency.style.color = "black";
        inputFieldForFrequency.style.width = "auto";
        inputFieldForFrequency.style.marginLeft = "1px";
        inputFieldForFrequency.style.marginRight = "1px";
        inputFieldForFrequency.style.padding = "1px";
        inputFieldForFrequency.style.border = "solid 1px #c9c9c9";

        inputFieldForDays.style.color = "black";
        inputFieldForDays.style.width = "45px";
        inputFieldForDays.style.marginLeft = "1px";
        inputFieldForDays.style.marginRight = "1px";
        inputFieldForDays.style.marginTop = "2px";
        inputFieldForDays.style.textAlign = "center";
        inputFieldForDays.style.padding = "1px";
        inputFieldForDays.style.border = "solid 1px #c9c9c9";
        inputFieldForDose.setAttribute('type', 'number');
        inputFieldForDays.setAttribute('type', 'number');
        if (inputFieldForFrequency.selectedIndex == -1) {
            var start = '';
            var len = prescriptionFrequenciesData.length;
            for (var i = 0; i < len; i++) {
                start += '<option value="' + prescriptionFrequenciesData[i].value + '">' + prescriptionFrequenciesData[i].title;
            }
            inputFieldForFrequency.innerHTML = start;
            }
            inputFieldForFrequency.required = true;
        divElement.appendChild(inputFieldForDose);
        divElement.appendChild(tablet);
        divElement.appendChild(inputFieldForFrequency);
        divElement.appendChild(forData);
        divElement.appendChild(inputFieldForDays);
        divElement.appendChild(days);
        listElement.appendChild(divElement);

        originalList[0].prepend(listElement);
        inputFieldForDose.addEventListener('click', function(){
            editFieldCheck = true;
            console.log("clicked");
            inputFieldForDose.focus();
            $(".tt-menu").show();
            inputFieldForDose.focus();
        })
        inputFieldForFrequency.addEventListener('click', function(){
            editFieldCheck = true;
            console.log("clicked");
            inputFieldForFrequency.focus();
            $(".tt-menu").show();
            inputFieldForFrequency.focus();
        })
        inputFieldForDays.addEventListener('click', function(){
            editFieldCheck = true;
            console.log("clicked");
            inputFieldForDays.focus();
            $(".tt-menu").show();
            inputFieldForDays.focus();
        })
    }

这里inputFieldForDays是元素的元素。和$(“。tt-menu”)用于bloodhound.js列表

0 个答案:

没有答案