Javascript conversion, from Prototype to jQuery

Posted by moshimoshi on Stack Overflow See other posts from Stack Overflow or by moshimoshi
Published on 2010-04-22T20:43:09Z Indexed on 2010/05/06 4:08 UTC
Read the original article Hit count: 307

Hi,

I would like to update the following javascript code based on Prototype framework to jQuery framework:

Event.observe(window, 'load', function() {
  $$('.piece').each(function(item) {
    new Draggable(item, { revert: true } );
  });

  $$('.cell').each(function(item) {
    Droppables.add(item, {
      accept: 'piece',
      onDrop: function(piece, cell) {
        cell.descendants().each(function(item) { item.remove(); } );

        piece.remove();
        piece.setStyle({ 'top': null, 'left': null });
        new Draggable(piece, { revert: true });
        cell.appendChild(piece);
      }
    });
  });
});

The first part of the script is easy to convert:

$(function() {
  $('.piece').draggable(
    {
      evert: true
    }
  );

  $('.cell').droppable(
    {
      /* But here, it's more difficult. Right? ;)
      ... */
    }
  });
});

Have you got an idea? Any part of code is welcome. Thanks a lot.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ui