Created
October 15, 2011 20:58
-
-
Save ryanneufeld/1290131 to your computer and use it in GitHub Desktop.
droppable problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$gallery | |
.sortable( { | |
opacity: 0.6, | |
appendTo: 'body', | |
cancel: "a.btn", | |
connectWith: '.gallery', | |
stop:function( event,ui ){ | |
console.log(event, ui); | |
//event.stopPropagation(); | |
} | |
} ) | |
.disableSelection(); | |
$recent.disableSelection(); | |
$( '#gallery-thumbs-1 > li' ) | |
.draggable({ | |
cancel: "a.btn", // clicking an icon won't initiate dragging | |
revert: "invalid", // when not dropped, the item will revert back to its initial position | |
helper: "clone", | |
cursor: "move", | |
appendTo: 'body' | |
}); | |
$gallery.droppable({ | |
accept: "li", | |
activeClass: "ui-state-highlight", | |
drop: function(event, ui){ | |
console.log(event, ui); | |
var img = ui.draggable.find( 'img' ).first(); | |
filename = img.attr( 'src' ), | |
ary = filename.split( "/" ); | |
filename = ary[ary.length - 1]; | |
$.getJSON( "/admin/galleries/addImage/" + img.data( 'id' ) + "/" + galleryid ).done( function( result ){ | |
if( result.result ) { | |
ui.draggable.draggable( "option", "disabled", true ); | |
$( '#msg-no-images' ).remove(); | |
$( '#tmpl-image-thumb' ) | |
.tmpl( {filename: filename, gpid: result.result} ) | |
.hide() | |
.appendTo( $gallery ) | |
.fadeIn(); | |
$gallery.addClass( 'valid-drop' ); | |
setTimeout(function(){ | |
$gallery.removeClass( 'valid-drop' ); | |
},2000); | |
} else { | |
$gallery.addClass( 'invalid-drop' ); | |
setTimeout(function(){ | |
$gallery.removeClass( 'invalid-drop' ); | |
},2000); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment