0

当我在 jquerymobile 中完成选择后,我想刷新我的页面。现在我使用 tag 中的 onchange 属性。这是我的代码。

<div data-role="fieldcontain" style = "background-color:white;border-bottom:1px solid #ccc">
    <label for="select-choice-1" class="select">select specity:</label>
    <select name="select-choice-1" id="select-choice-1" data-native-menu = false multiple=true onchange = "selectChange()"></select>
</div>

$("#select-choice-1").empty();
for (var i = 0; i < item.tagClassList.length; i++) {
    if (item.tagClassList[i].isSelected) {
        $("#select-choice-1").append("<option value="+item.tagClassList[i].id+"checked = true>"+item.tagClassList[i].className+"</option>");
    } else {
        $("#select-choice-1").append("<option value="+item.tagClassList[i].id+">"+item.tagClassList[i].className+"</option>");
    }
    if (i == item.tagClassList.length-1) {
        $("#select-choice-1").selectmenu("refresh");
    };
};

But the selectmenu() event fires whenever select is selected or selected is cancelled.How can I get the event fires when the selectmenu is closed

4

1 回答 1

0

try binding to blur() like so

$('document').on('blur', '#select-choice-1', function(){
    //run your check here
    });

this also takes care of older versions of ios which seem to not fire change events on multiple selects.

于 2012-04-27T05:42:25.347 回答