Answered here
http://groups.google.com/group/jquery-en/browse_thread/thread/6baa555a340b3ec4

- Richard

On Fri, Dec 18, 2009 at 5:28 AM, Alex Beston <alex.bes...@gmail.com> wrote:

> Hi there,
>
> I'm trying to create some words which can be dragged and dropped into a
> container (called droppable).
>
> I've tried to dynamically create some divs each containing a word, and they
> can be dragged okay, but when I try to drop, it isnt recognised.
>
> I notice  that if I have a static div in the script it will be recognised
> by the droppable area (as per the example on the jquery site)
>
> thanks in advance,
>
> Alex
>
> ---------
>
> Heres the code I have so far:
>
> var these = [ 'red', 'blue', 'green', 'orange',  'white' ];
>
> function makeButtons() {
>  for (i in these)
> makeWord(these[i]);
> }
>
> function makeWord(s) {
> var e = $(document.createElement('div'));
> e.attr('id', s);     // make a div with id orange / white / etc
>  e.append(s);
> e.draggable( );   // make this div draggable
> $('body').append(e);
> }
>
> function initialise(){
> makeButtons();
> $(function(){
>  $("#droppable").droppable({
>     drop: function( ) { alert('dropped'); }
>   });
> });
> }
>
> // html
>
> <head>
> <script type="text/javascript">
>  $(document).ready( initialise );
> </script>
> </head>
> <body>
> <div id="droppable"  ></div>
> </body>
>
>
> ---------------------------------------------------------------------
>
>
>
> --
> rgds, Alex
> ---------------------------------------------------------------------
>

Reply via email to