2012-05-07 53 views
0

我想開發一些拖放功能。 首先,我只是想要拖動的東西。 我正在讀一本書「開始使用Dojo,Kyle Hayes」,但我沒有運氣。即使獲得基本的dojo工作也沒有運氣

我的一些問題:

  1. 當我連接到最新的道場和谷歌的圖書館,沒有什麼工作都沒有。
  2. 每當我在我的初始腳本中調用djConfig="parseOnLoad來調用谷歌較舊的庫時,什麼都不起作用。如果我拿出djConfig="parseOnLoad,那麼該頁面開始工作。
  3. 如果我包含dojo.require("dojo.dnd.Target"),我將失去所有功能。
  4. 無論我做什麼,我都無法得到一個簡單的div來拖動。

我在下面列入了我的代碼,並衷心感謝任何人都可以幫助我入門。

<!DOCTYPE HTML> 
<html> 
<head> 
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"                 djConfig="parseOnLoad: true"></script> 

<script type="text/javascript"> 
     //dojo.require("dojo.parser"); 
     dojo.require("dojo.dnd.move"); 
     dojo.require("dojo.dnd.Source"); 
     //dojo.require("dojo.dnd.Target"); 
     dojo.require("dijit.form.Button"); 
     dojo.require("dijit.form.TextBox"); 
     document.write("I got this far"); 

    var init = function() 
    { 
     dojo.connect(
     dojo.byId('btnSayHello'), 
     "onclick", 
     this, 
     helloButton_onClick 
     ); 
    } 


    var helloButton_onClick = function(event) 
    { 
     alert ('Hello World and hello ' + dojo.byId('txtName').value + '!'); 
    } 

    dojo.addOnLoad(init); 
</script> 
</head> 
<body> 
<div id="dragMe" dojoType="dojo.dnd.move" style="border: 1 solid black; height: 300; width: 300;"> 
Source 1 
</div> 
<div id=Div1 dojoType="dojo.dnd.Target" style="border: 1 solid black; height: 300; width: 300;"> 
    Target 
</div> 
<div> 
    <h1>Hello World Example</h1> 
    <hr/> 
    <label for="txtName">Your name:</label> 
    <input id="txtName" type="text" dojoType="dijit.form.TextBox"/><br/> 
    <button id="btnSayHello" dojoType="dijit.form.Button">Say Hello</button> 
</body> 
</html> 

回答

1

我剛從dojoType="dojo.dnd.move"變更爲dojoType="dojo.dnd.Moveable",我可以拖動它。希望能幫助到你。

相關問題