EasyUI Forum
May 04, 2024, 05:50:32 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: draggable by dynamic title  (Read 4421 times)
catpaw
Jr. Member
**
Posts: 85


View Profile Email
« on: March 30, 2016, 01:47:39 PM »

hello all

I´m using for first time the draggable plugin and I need some help

I have a loop with draggable boxes but I want it can only drag by the title , which is through by the handle property

but as these boxes are created dynamically have no way to assign the property to every one, because the assignment of doing through a class all divs

Code:
$(function(){
var indicator = $('<div class="indicator">>></div>').appendTo('body');
$('.drag-item').draggable({
revert:true,
deltaX:0,
deltaY:0,
onDrag: function onDrag(e){
var d = e.data;
if (d.left < 0){d.left = 0}
if (d.top < 0){d.top = 0}
if (d.left + $(d.target).outerWidth() > $(d.parent).width()){
d.left = $(d.parent).width() - $(d.target).outerWidth();
}
if (d.top + $(d.target).outerHeight() > $(d.parent).height()){
d.top = $(d.parent).height() - $(d.target).outerHeight();
}
}
}).droppable({
onDragOver:function(e,source){
indicator.css({
display:'block',
left:$(this).offset().left-10,
top:$(this).offset().top+$(this).outerHeight()-5
});
},
onDragLeave:function(e,source){
indicator.hide();
},
onDrop:function(e,source){
//$(source).insertAfter(this);
$(source).insertBefore(this);
indicator.hide();
}
});
});

I have relied on the example of the demos

Now this is how I create the boxes inside the loop

Code:
<div class="easyui-panel" style="position:relative;overflow:hidden;width:auto;height:350px;padding:5px 2px;">
            <?php 
foreach($array as $item){
$name explode("|",$item);
$indice $name[0];
$titulo $name[1];
?>

             <div id="<?php echo $indice?>" class="drag-item">
                 <div class="title-item"><?php echo $titulo?></div>
                </div>
             <?php
}
?>

        </div>

How I can add the handle with a different title for each item?

thanks
« Last Edit: March 30, 2016, 01:50:06 PM by catpaw » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!