如何正确使用Worklight内的Dojo? [英] How do I use Dojo inside of Worklight correctly?

查看:100
本文介绍了如何正确使用Worklight内的Dojo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助,以及如何在我的项目中正确使用Dojo的一些建议。目前,这正是我正在做的:

I need some help as well as some advice on how to use Dojo correctly in my project. At the moment, this is what I'm doing:

说我设置了一个名为Test的项目。 Test.html是第一个文件,在该文件中我有以下内容:

Say I setup a project named 'Test'. Test.html is the first file hit, and in that file I have the following:

<script type="text/javascript" data-dojo-config="isDebug: false, async: true, parseOnLoad: true" src="dojo/dojo.js"></script>
<script type="text/javascript" src="dojo/core-web-layer.js"></script>
<script type="text/javascript" src="dojo/mobile-ui-layer.js"></script>
<script type="text/javascript" src="dojo/mobile-compat-layer.js"></script>
<script type="text/javascript">
  require(
  // Set of module identifiers
  [ "dojo", "dojox/mobile/parser", "dojox/mobile/SwapView", "dojox/mobile", "dojox/mobile/compat", "dojox/mobile/deviceTheme", "dojox/mobile/ScrollableView" ],
  // Callback function, invoked on dependencies evaluation results  
  function(dojo) {
    dojo.ready(function() {});
  });
</script>   

我也在Test.js中有

I also have this in Test.js:

require([ "dojo", "dojox/mobile/parser", "dojox/mobile/deviceTheme",
  "dojox/mobile/ScrollableView", "dojox/mobile/compat", "dojox/mobile",
  "dojox/mobile/Button", "dojox/mobile/View", "dojox/mobile/Heading",
  "dojox/mobile/TabBarButton", "dojox/mobile/TabBar",
  "dojox/mobile/TextBox", "dojox/mobile/RoundRectList",
  "dojox/mobile/ListItem", "dojox/mobile/Button",
  "dojox/mobile/SpinWheel", "dojox/mobile/SpinWheelSlot",
  "dojox/mobile/IconContainer", "dojox/mobile/SwapView" ], 
  function(dojo, parser) {
    dojo.ready(function() {

    });
  });

现在,当我点击其中一个按钮时,它会触发WL.Page.Load方法我的pagePort div现在在我的Test.html页面中显示了我的新页面(让我们说这是Page2.html),但是有一个问题。 Dojo的东西在第一页工作正常,但现在在第二页上不起作用。我不知道幕后发生了什么,但我觉得我错过了一个步骤(我需要卸载Dojo吗?在下一页再次声明)。

Now, when I click a on one of my buttons, it triggers the WL.Page.Load method and my pagePort div now shows my new page inside of my Test.html page (let's say this is Page2.html), however, there's a problem. The Dojo stuff works fine on page one, but now it doesn't work on page two. I'm not sure what's happening behind the scenes but I feel I'm missing a step (do I need to unload Dojo? Declare it again in the next page?).

如果有人可以帮助我让Dojo在第二页上工作,所以我可以在进一步的页面上使用Dojo(在学习我做错了之后),我将非常感激!

If somebody could help me get Dojo working on this second page so I'm able to use Dojo on further pages (after learning what I'm doing wrong) I would be really grateful!

推荐答案

根据您给出的信息,我最好的猜测是,Page2.html并不在Test.html及其新页面中。在这种情况下,您将需要在第2页的脚本引用。

My best guess based on the info you've given is that Page2.html is not really inside Test.html and its a new page. In this case you will need to have the script references in Page2 as well.

如果您在网络浏览器中测试您的代码,您可以查看控制台,并希望能够了解到究竟发生了什么。

If you're testing your code in a web browser you can view the Console and hopefully gain some insight as to what exactly is going wrong.

您还可以尝试使用Worklight记录器来帮助找到问题。
http://wpcertification.blogspot.com /2012/03/enabling-debuglog-console-in-worklight.html

You can also try working with the Worklight logger to help locate the problem. http://wpcertification.blogspot.com/2012/03/enabling-debuglog-console-in-worklight.html

以下是IBM的问题确定的常规链接以及
http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp?topic=/com.ibm.iea.worklight/worklight/5.0/Problem_Determination/IMFV50_ProblemDetermination/ player.html

Here is a general link for "Problem Determination" from IBM as well http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp?topic=/com.ibm.iea.worklight/worklight/5.0/Problem_Determination/IMFV50_ProblemDetermination/player.html

这篇关于如何正确使用Worklight内的Dojo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆