Dragging and Dropping and Reloading
I have a book img and a few shelves that can contain other books. I
make the book draggable, and the shelves droppable, and in the
callback function of the shelves, I have a the same page load (it
processes itself) and update the group of shelves. When I do this, the
post request is sent successfully, but when I try and drag the book
again, I get a "parent has no properties" error.
I think I might have to re-bind the loaded shelves, but I'm not sure
how exactly to do that and let the book be added more than once. The
error is the most confusing part for me.
The Javascript:
Note: * the shelves have ids named "shelf-{name of shelf}")
* #newshelf is the big div holding all the containers (or shelves) and
extra stuff, while #shelf-critical-information just holds the actual
shelves
$(document).ready(function(){
$(".book-image").draggable({opacity:.8,helper:'clone'});
$(".shelf").droppable({
accept: ".book-image",
activeClass: "droppable-active",
hoverClass: "droppable-hover",
drop: function(ev, ui) {
var shelf = ui.droppable.element.id.split("-")[1];
console.debug($(parent));
$("#shelf-critical-information").load(". #newshelf
#shelf-critical-information",
{'library.addshelf':shelf,
'library.submit':'Submit'});
}});
});
The Error (from firebug):
parent has no properties
offset()jquery-latest.js (line 2958)
prepareOffsets(Object element=img.book-image options=Object rpos=[2],
Object type=dragstart target=img.book-image)ui.draggable.js (line 36)
start(Object interaction=Object plugins=Object, Object type=dragstart
target=img.book-image)ui.draggable.js (line 141)
_start(img.book-image 300, [399, 319], Object top=197 left=163
bottom=0 right=0, Object element=img.book-image options=Object
rpos=[2], Object type=dragstart target=img.book-image)ui.draggable.js
(line 86)
start(Object type=dragstart target=img.book-image)ui.mouse.js (line
182)
drag(Object type=dragstart target=img.book-image)ui.mouse.js (line
226)
mousemove(Object type=dragstart target=img.book-image)ui.mouse.js
(line 116)
handle(Object type=dragstart target=img.book-image)jquery-latest.js
(line 1776)
(no name)()jquery-latest.js (line 1620)
[Break on this error] while ( parent.tagName && !/^body|html$/
i.test(parent.tagName) ) {