JQuery Mobile simpledialog清除页面中的动态数据

Aru*_*run 5 jquery-mobile

JQuery Mobile simpledialog()从页面中清除我的动态数据.实际上我有一个列表,我使用simpledialog提示从中删除记录.但这将清除我动态生成的列表,所以我必须重新加载页面以获取列表.有没有选择摆脱这个.

以下是我的代码:

$('#Delete').simpledialog({

'mode': 'bool',
'prompt': 'Are you sure to deactivate'?',
'useModal': true,
'buttons': {
    'OK': {
        click: function () {
            $('#dialogoutput').text('OK');
            $.ajax({
                type: 'POST',
                url: deactivateUrl,
                data: { postVar: postDeactivate },
                beforeSend: function () {
                    showPageLoading("De-Activating..");
                },
                success: function (data) {
                    hidePageLoading();
                    if (data = 'true') {
                        notification("Record Deactivated!");
                        location.reload();
                    }
                    else {
                        notification("Deactivation failed.");
                    }
                },
                error: function () {
                    //alert("Error");
                }
            });

        }
    },
    'Cancel': {
        click: function () {
            $('#dialogoutput').text('Cancel');
            location.reload();
        },
        icon: "delete",
        theme: "c"
    }
}
});
Run Code Online (Sandbox Code Playgroud)

Red*_*678 0

你有,

if (data = 'true') {
    notification("Record Deactivated!");
    location.reload();
}
else
{
    notification("Deactivation failed.");
}
Run Code Online (Sandbox Code Playgroud)

这:

if (data = 'true')
Run Code Online (Sandbox Code Playgroud)

当您使用单个等于将其设置为“true”时,它将始终为“true”。

也许你想要:

if (data == 'true')
Run Code Online (Sandbox Code Playgroud)

或者

if (data === true)
Run Code Online (Sandbox Code Playgroud)