首页 > 解决方案 > 花式树:如何根据结果调用两个端点

问题描述

我在我的应用程序 UI 中使用花哨的树:

f_tree = $("#nodes_tree").fancytree({
        extensions: ["table"],
        table: {
            indentation: 24,
            nodeColumnIdx: 0
        },
        source: [
            {
                title: "/",
                key: "jcr:root",
                folder: true,
                lazy: true,
            }
        ],
        lazyLoad: function (event, data) {
            let node = data.node;
            let path = buildPath(node);
            if (path !== '/') {
                data.result = {
                    url: 'http://localHost:8080/getDetails'
                };
            } else {
                data.result = elasticResponse;
            }
        },
        postProcess: function (event, data) {
            if (data.response) {
                data.result = data.response._paths;
            }
        },
        renderColumns: function (event, data) {
            let d = data.node.data,
                $tdList = $(data.node.tr).find(">td");
            if (d.attributes) {
                //console.info(`step 333`);
                $tdList.eq(1).text(d.attributes['title'])         
            }
        }
});

我无法编写条件,如果“http://localHost:8080/getDetails/1234”将返回 {} 空白 json 响应而不是 {"_paths":[{"title":"..."}]" } 响应然后它应该调用另一个 url 即;“http://localHost:8087/getAnotherDetails/1234”。请让我知道如何在花哨的树中实现这一点。

标签: javascriptjqueryfancytree

解决方案


推荐阅读