以编程方式在回调中填充jQuery mobile中的复选框

Phi*_*enn 0 checkbox jquery-mobile

文档说要使用:

$("input[type='checkbox']").bind( "change", function(event, ui) {
Run Code Online (Sandbox Code Playgroud)

但我想知道这是否仍然存在

$("input:checkbox]").on('change', function(event, ui) {
Run Code Online (Sandbox Code Playgroud)

此外,我想停止检查显示,然后以编程方式在回调运行时显示它.

解决方案可能包括刷新方法.

Phi*_*enn 9

你想用

$(this).removeAttr('checked').checkboxradio('refresh');
Run Code Online (Sandbox Code Playgroud)

关闭复选框然后关闭

$(this).prop('checked',true).checkboxradio('refresh');
Run Code Online (Sandbox Code Playgroud)

把它重新打开.

$('input:checkbox').on('change', function(myEvent, ui) {
    var settings = {};
    settings.data = {};
    settings.data.PersonID = $(this).val();
    settings.data.EvntID = $('#EvntID').val();

    if ($(this).is(':checked')) {
        $(this).removeAttr('checked').checkboxradio('refresh');
        settings.data.method = 'check';
        settings.context = this;
        myXHR = $(this).myAjax('Evnt.cfc',settings);
        myXHR.done(function(result) {
            if (!result.MSG) {
                $(this).prop('checked',true).checkboxradio('refresh');
            }
        });
    } else {
        $(this).prop('checked',true).checkboxradio('refresh');
        settings.data.method = 'uncheck';
        myXHR = $(this).myAjax('Evnt.cfc',settings);
        myXHR.done(function(result) {
            if (!result.MSG) {
                $(this).removeAttr('checked').checkboxradio('refresh');
            }
        });
    }
});
Run Code Online (Sandbox Code Playgroud)