【问题标题】:recheck outer if boolean true or false within it's else如果 boolean true 或 false 在它的 else 中,重新检查外部
【发布时间】:2020-07-18 13:07:15
【问题描述】:

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

    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
        });
    }

【问题讨论】:

    标签: if-statement kendo-ui return boolean


    【解决方案1】:

    我认为你需要简单的递归,我看不到整个代码,所以我无法准确判断。

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

    【讨论】:

      猜你喜欢
      • 2016-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-29
      • 1970-01-01
      • 2013-06-22
      • 1970-01-01
      • 2023-04-04
      相关资源
      最近更新 更多