【问题标题】:Fancytree does not execute in a Bootstrap modalFancytree 不在 Bootstrap 模式中执行
【发布时间】:2015-06-30 08:41:58
【问题描述】:

我在 Bootstrap 中使用了 fancytree 插件。它在标准页面上运行良好,但是在模式中调用时,它什么也不做。

函数被声明,jQuery().fancytree 返回 true。

我也无法获得调试输出,所以看起来它根本没有被调用

定义了一个 id 为 ntree 的 DIV

我在模态中的 HTML

<div id="ntree"><div>
<script type="text/javascript">
jQuery(document).ready(function(){
    // Create the tree inside the <div id="tree"> element.
    console.log(jQuery().fancytree);
    if (jQuery().fancytree){
        alert("function exists");
        $("#ntree").fancytree({
            children: [ // Pass an array of nodes.
                {title: "Item 1"},
                {title: "Folder 2", isFolder: true,
                    children: [
                        {title: "Sub-item 2.1"},
                        {title: "Sub-item 2.2"}
                    ]
                },
                {title: "Item 3"}
            ],
            debugLevel: 2
        });
    } else {
        alert("Fancytree is not declared");
    }
});
</script>

【问题讨论】:

  • 我向这个论坛道歉,因为在最初的帖子中没有提供足够的信息。我借此机会提供更多信息,以及经过更多努力后的发现,我正在寻求在 Vtiger CRM 的模态对话框中实施 fancytree。毫无疑问,它可以通过其他方式实现,就像我在 Vtiger 的其他 UI 组件中所做的那样,作为 Vtiger 小部件。下面的屏幕截图链接显示了结果。 screencast.com/t/Wo37GoBMN8R
  • Vtiger CRM 是许多开源库的实现,主要是用于 UI 的 jQuery 和 Bootstrap。在模态调用点,显示在屏幕上,有许多 css 和 js 在动作之前被调用。我的挑战是让它在 Vtiger 呈现的模态下工作。我能够使用与我的 Vtiger 实例中相同的 CSS 和 js 资源制作小提琴,并且 fancytree 组件运行良好。 jsfiddle.net/stprasad/fn0udjvo/4
  • 我在目标环境中的各种加载点(包括 Header.tpl 和 JSResource.tpl)中包含了用于花式树的 CSS 和 JS,以查看是否有任何 CSS / JS 冲突世界得到解决。但似乎没有任何效果。我怀疑某处存在冲突,因为我可以使用评估为 true 的 if(Jquery.functiontree) 来确认函数的加载和存在。更多努力后

标签: jquery twitter-bootstrap modal-dialog fancytree


【解决方案1】:

使用 'source' 属性而不是 'children'。

jsfiddle; http://jsfiddle.net/Lu2a67b2/

JS:

jQuery(document).ready(function(){
    // Create the tree inside the <div id="tree"> element.
    console.log(jQuery().fancytree);
    if (jQuery().fancytree){
        alert("function exists");
        $("#ntree").fancytree({
            source: [ // Pass an array of nodes.
                {title: "Item 1"},
                {title: "Folder 2", isFolder: true,
                    children: [
                        {title: "Sub-item 2.1"},
                        {title: "Sub-item 2.2"}
                    ]
                },
                {title: "Item 3"}
            ],
            debugLevel: 2
        });
    } else {
        alert("Fancytree is not declared");
    }
});

【讨论】:

  • 您好,非常感谢您的回复。我正在使用源代码,但在阅读了其他地方的另一个示例后改为儿童。也许我应该更清楚地表达我的观点,我现在就这样做。
  • 我的环境在一个名为 Vtiger 的 CRM 中,它使用 jQuery、jQuery UI 和 Bootstrap 以及许多其他插件和插件。我怀疑加载的东西,css 或 js 正在破坏它,我用最新的引导程序在 Tryit 上进行了测试,它在那里工作。我能够在jsfiddle.net/stprasad/3ksjkL19 上构建相同的内容,并且效果很好,我将尝试在小提琴上模仿确切的库并分享结果
猜你喜欢
  • 2018-03-19
  • 2018-08-28
  • 2015-08-24
  • 1970-01-01
  • 2019-07-03
  • 2016-12-08
  • 2019-01-26
  • 2014-02-10
  • 1970-01-01
相关资源
最近更新 更多