新手道场 - Google CDN 问题

发布于 2024-09-27 12:16:15 字数 1189 浏览 0 评论 0 原文

我有一个测试jsp:

<head>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" type="text/javascript">
</script>

<script type="text/javascript"> 
dojo.require("dojo.widget.Tree"); 
dojo.require("dojo.widget.TreeSelector"); 
dojo.require("dojo.widget.TreeNode"); 
dojo.require("dojo.widget.TreeContextMenu"); 
</script> 
</head>

<body>
<div dojoType="TreeSelector" widgetId="treeSelector"></div> 
<div dojoType="Tree" widgetId="treeWidget" selector="treeSelector"toggler="wipe"> 
<div dojoType="TreeNode" widgetId="1" title="First node" isFolder="false"></div> 
<div dojoType="TreeNode" widgetId="2" title="Second node"> 
    <div dojoType="TreeNode" widgetId="2.1" title="Second node First Child"></div> 
    <div dojoType="TreeNode" widgetId="2.2" title="Second node Second Child"></div> 
</div> 
<div dojoType="TreeNode" widgetId="3" title="Third node" isFolder="false"></div> 
</div>

这在任何浏览器中都不起作用。 我认为这很容易,似乎 dojo 库没有被下载/找到? 我还需要做其他事情吗?

另外,我的 IDE JDeveloper 报告元素 div 上未定义属性“dojoType”。

I have a test jsp with:

<head>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" type="text/javascript">
</script>

<script type="text/javascript"> 
dojo.require("dojo.widget.Tree"); 
dojo.require("dojo.widget.TreeSelector"); 
dojo.require("dojo.widget.TreeNode"); 
dojo.require("dojo.widget.TreeContextMenu"); 
</script> 
</head>

<body>
<div dojoType="TreeSelector" widgetId="treeSelector"></div> 
<div dojoType="Tree" widgetId="treeWidget" selector="treeSelector"toggler="wipe"> 
<div dojoType="TreeNode" widgetId="1" title="First node" isFolder="false"></div> 
<div dojoType="TreeNode" widgetId="2" title="Second node"> 
    <div dojoType="TreeNode" widgetId="2.1" title="Second node First Child"></div> 
    <div dojoType="TreeNode" widgetId="2.2" title="Second node Second Child"></div> 
</div> 
<div dojoType="TreeNode" widgetId="3" title="Third node" isFolder="false"></div> 
</div>

This will not work in any browser.
I thought this would be easy, it seems the dojo library is not being downloaded/found?
Do I need to do anything else?

Also, my IDE, JDeveloper, reports that the attribute "dojoType" is not defined on element div.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

耀眼的星火 2024-10-04 12:16:15

我不得不说,这个示例看起来像是取自 非常 的 dojo 版本,但您正尝试在 Dojo 1.5 上运行它。这很可能行不通。 dojo.widget 从...0.4 开始就不存在了,也许是 0.9 以后。

您对前面的答案的评论可能是正确的,因为在原始示例中不需要 parseOnLoad: true ,但我也向您保证,该示例没有在附近运行任何版本的 Dojo你用什么来运行它。

根据您在那里看到的内容,您可能想从这里开始: http://www.dojotoolkit.org/reference-guide/dijit/Tree.html

I have to say, this example looks like it is taken from a very old version of dojo, but you're trying to run it against Dojo 1.5. That most likely won't work. dojo.widget hasn't existed since...0.4, 0.9 maybe.

You may be right in your comment to the previous answer in that no parseOnLoad: true was necessary in the original example, but I'd also assure you that that example was not running any version of Dojo anywhere near what you're running it with.

Based on what you're looking at there, you may want to start somewhere like here: http://www.dojotoolkit.org/reference-guide/dijit/Tree.html

蹲在坟头点根烟 2024-10-04 12:16:15

我不确定它不存在时的默认行为是什么,但您可能需要定义一个 djConfig 并将 parseOnLoad 设置为 true (或直接调用解析器)。有关详细信息,请参阅以下链接:

http://docs.dojocampus.org/djConfig

http://dojocampus.org/content/2008/03/08/the-dojo-解析器/

I'm not sure what the default behavior is when it's not present, but you probably need to define a djConfig with parseOnLoad set to true (or call the parser directly). See the following links for more information:

http://docs.dojocampus.org/djConfig

http://dojocampus.org/content/2008/03/08/the-dojo-parser/

空城仅有旧梦在 2024-10-04 12:16:15

请遵循:

您需要:

  • 注册 API 密钥(或使用直接链接正如您所做的那样),
  • 如果不使用直接链接而是使用 google.load,则需要使用 onload 回调推迟代码的执行。

就我个人而言,我会做类似的事情:

my.html 部分中:

<script type="text/javascript" src="http://www.google.com/jsapi?key=MY_API_KEY_GOES_HERE"></script>
<script type="text/javascript" src="my.js"></script>

in my.js< /em>:

google.load("dojo", "1.5", {
  uncompressed: true
});

function OnLoad() {
  /* do stuff here */
}

google.setOnLoadCallback(OnLoad);

Follow the:

You need to:

  • register for an API key (or use a direct link as you did),
  • if not using a direct link but google.load, you need to defer the execution of your code using an onload callback.

Personally, I would just do something like:

within the <head> section of my.html:

<script type="text/javascript" src="http://www.google.com/jsapi?key=MY_API_KEY_GOES_HERE"></script>
<script type="text/javascript" src="my.js"></script>

in my.js:

google.load("dojo", "1.5", {
  uncompressed: true
});

function OnLoad() {
  /* do stuff here */
}

google.setOnLoadCallback(OnLoad);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文