重新检查外部,如果布尔值为true或false,则为else

时间:2020-04-06 13:52:42

标签: if-statement kendo-ui return boolean

我的目标是重新检查变量coolFeature的布尔值else

    if (coolFeature) { // want to run this again after value becomes true in else below
        $("#Editor").data("kendoWindow").width = '600';
        $("#Editor").data("kendoWindow").title("Format Feature - " + Type + ' #' + graphic.attributes.OBJECTID);
        $('#ndt').hide();
    } else {
        $("#Editor").data("kendoWindow").title("Edit Attributes - " + Type + ' #' + graphic.attributes.OBJECTID);
        $('#ndt').show();
        $("#ndt").click(function() {
            $(this).data('clicked', true);
            $("#Editor").data("kendoWindow").hide();
            coolFeature = "true"; // want to reset to True here, then run the actions under initial if
        });
    }

1 个答案:

答案 0 :(得分:0)

我认为您需要简单的递归,我看不到完整的代码,所以我不能确切地说出来。

var myFunction = function(coolFeature) {
    if(coolFeature) {
        console.log("Cool");
    } else {
        myFunction(true);
    }
};

myFunction(false);