Milkbones
Milkbones

Reputation: 41

Having no luck at all even getting basic dojo to work

I am trying to develop some drag and drop functionality. First, I just want the thing to drag. I'm reading a book "Getting Started with Dojo, Kyle Hayes", but am having no luck.

Some of my problems:

  1. When I connect to the newest dojo and Google's library, nothing works at all.
  2. Whenever I include djConfig="parseOnLoad in my initial script calling an older library from Google, nothing works. If I take out the djConfig="parseOnLoad, then the page begins to work.
  3. If I include dojo.require("dojo.dnd.Target"), I lose all functionality.
  4. and no matter what I do, I cannot get a simple div to drag.

I have included my code below, and sincerely appreciate any help anyone can give me in getting started.

<!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>

Upvotes: 0

Views: 203

Answers (1)

LaLeX
LaLeX

Reputation: 198

I just changed from dojoType="dojo.dnd.move" to dojoType="dojo.dnd.Moveable" and I can drag it around. Hope it helps.

Upvotes: 1

Related Questions