-1

以下のコード内のコメントを参照してください。

$('#btnDelete').on('click', function()
{
    var treeView = $("#treeview").data("kendoTreeView");
    var userId = $('#user_id').val();

    $('#treeview').find('input:checkbox:checked').each(function()
    {
        debugger;

        var li = $(this).closest(".k-item")[0];
        var notificationId = treeView.dataSource.getByUid(li.getAttribute('data-uid')).ID;

        if (notificationId == undefined)
        {
              //if the notification ID is "undefined" here, I want the ".EACH" 'loop' to continue to the next item.
        }
        $.ajax(
            {
                url: '../api/notifications/deleteNotification?userId=' + userId + '&notificationId=' + notificationId,
                type: 'DELETE'
            }).done(function()
            {
                var treeview = $("#treeview").data("kendoTreeView");
                treeview.destroy();
                CreateNotificationTree(userId);
                console.log('Delete successful.');
            }).fail(function(jqXHR, status, error)
            {
                console.log("Error : " + error);
            });
        treeView.remove($(this).closest('.k-item'));

    });
});
4

2 に答える 2

0
return false;

非常にシンプルで、break従来のループと同じように機能します

編集:申し訳ありませんが、中断するのではなく、続行する必要があります。ごめん。

于 2013-08-19T22:16:47.227 に答える