I use jQuery UI drag&drop functions to select images an album. The images ID straged in the rel parameter, what I need to copy to an input element after image drop.
Here is the image list. Using draggable
<img src="01.jpg" title="image 01" rel="10" />
<img src="02.jpg" title="image 02" rel="11" />
<img src="03.jpg" title="image 03" rel="12" />
Drop here:
<div id="dropzone">
<div id="imgcontainer"></div>
<input type="text" name="img_id" id="img_id" />
</div>
The droppable JS code is here:
$('#dropzone').droppable({
hoverClass: 'bgSelected',
drop: function(event, ui) {
$(this).html(''); // to remove any other stuffs
var img = ui.draggable;
$('<img src="'+img.prop('src')+'" title="'+img.prop('title')+'">').appendTo( $(this) );
$('<input type="text" name="img_id" id="img_id" value="'+img.prop('rel')+'" />').appendTo( $(this) );
},
});
And the img.prop('rel') return with empty string. I tried to use img.attr('rel'), but that return an object element. How can I get the "rel" value?