AshesOfOwls / jquery.shapeshift

A dynamic grid system with drag and drop functionality.
http://ashesofowls.github.com/jquery.shapeshift/
MIT License
1.67k stars 311 forks source link

Uncaught Error: cannot call methods on draggable prior to initialization #108

Open noctivityinc opened 10 years ago

noctivityinc commented 10 years ago

We are initializing shapeshift as such:

      $tileContainer.shapeshift
        dragWhitelist: '.tile.draggable'
        enableDrag: true
        cutoffStart: 2

and have some draggable and non draggable tiles:

 <div class='tileContainer'>
     <div class="tile"></div>
     <div class="tile"></div>
     <div class="tile draggable"></div>
     <div class="tile draggable"></div>
     <div class="tile draggable"></div>
</div>

when we add an item to the tile container like such:

   $tile.insertAfter('.tile:first')

we need to call ss-destroy to bind the new item (calling ss-rearrange did NOT work to bind the inserted item).

If we call it like this (coffeescript):

     $tileContainer.trigger("ss-destroy").shapeshift
         dragWhitelist: '.tile.draggable'

Then we get the error:

   Uncaught Error: cannot call methods on draggable prior to initialization

But if we make every tile draggable then we do not get this error.