0

jquerymobileでselectを選択し終えたら、ページを更新したいと思います。次に、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");
    };
};

ただし、selectmenu()イベントは、selectが選択されているか、選択がキャンセルされている場合に発生します。selectmenuを閉じたときにイベントを発生させるにはどうすればよいですか。

4

1 に答える 1

0

そのようにblur()にバインドしてみてください

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

これは、複数の選択で変更イベントを発生させないように見える古いバージョンのiosも処理します。

于 2012-04-27T05:42:25.347 に答える