views:

60

answers:

1

i am new to dojo actually i have three divs and div no1. have 10 pictures and other two divs are empty. i want user can drag pictures to any div (2,3) or drag back to div1 in last i want to store in db using php.

can any body help me.?

+1  A: 

As for the dragging and dropping, you'll need to use dojo.dnd.Source.

In your Js, you'll need:

dojo.require("dojo.dnd.Source");

Your HTML will look like this (for the most part):

<div dojoType="dojo.dnd.Source" id="div1">
  <div class="dojoDndItem">
      <img />
  </div>
  <div class="dojoDndItem">
      <img />
  </div>
  ... 8 more times ...
</div>

I set up a simple example using google's logo that you can drag from one div to another on jsbin.

As for saving to a database, I'm unclear on what you want to save. The src? Something else?

That being said, you could use dojo.query to get the images of a certain div to call an xhrGet to your PHP page/service.

Basically:

 dojo.query("img",dojo.byId("div1")).forEach( function() {
     // this is now the image
     dojo.xhrGet( { url: '/somepage.php',
                    data: { image_name: this.title } // ???: depends on what you want
                    load: function( data ) {
                      alert("I worked!");
                    },
                    error: function( data ) {
                       alert("O NOES!!!");
                    }
                }
    );
 });
seth
Many Thanksnice, that's what i need, a little problem with drag and drop when i start to drag image move little down and right which don't look good, can we fix it so its look like nice.
air