Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取扩展属性JQuery_Jquery_Attributes_Sapui5 - Fatal编程技术网

获取扩展属性JQuery

获取扩展属性JQuery,jquery,attributes,sapui5,Jquery,Attributes,Sapui5,我得到了以下代码片段: onAfterRendering: function() { //#oTree-TreeCont: oTree -> ID des Tree, -TreeCont -> Konstante die den Content Bereich anspricht $('#oTree-TreeCont ul li').click(function(){ var $aria = $(this).attr("aria-expanded");

我得到了以下代码片段:

onAfterRendering: function() {
    //#oTree-TreeCont: oTree -> ID des Tree, -TreeCont -> Konstante die den Content Bereich anspricht
    $('#oTree-TreeCont ul li').click(function(){
        var $aria = $(this).attr("aria-expanded");
        if($aria){ //Element wurde aufgeklappt
            alert($aria);
            var clickedNode = $(this).attr("id"); //Erfrage ID
            //Lade alle Childs der 'clickedNode'
            sap.ui.getCore().byId("idOrganisation_Home1").getController().loadChildNodes(clickedNode);
        }
    });

}
我希望,如果树(SAPUI5)被展开,那么一个方法应该加载这个节点的子元素。问题是,它警告“真”,但也警告“假”

为什么会发生这种情况?这部分
if($aria){}
应该测试该值是否为真,但如果为假,则执行
if
语句的主体,为什么


感谢您的帮助:)

因为当前属性值被视为字符串值,而不是布尔值。 你需要像这样检查

if($aria=="true")

因为当前属性值被视为字符串值,而不是布尔值。 你需要像这样检查

if($aria=="true")

非常感谢,我对整个主题一无所知,非常感谢:)非常感谢,我对整个主题一无所知,非常感谢:)