Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取在jQuery UI中移动的portlet的id_Jquery_Jquery Ui_Jquery Ui Sortable - Fatal编程技术网

获取在jQuery UI中移动的portlet的id

获取在jQuery UI中移动的portlet的id,jquery,jquery-ui,jquery-ui-sortable,Jquery,Jquery Ui,Jquery Ui Sortable,我将jqueryui用于分配数据id的所有portlet。 一个portlet元素的HTML结构如下所示: <div class="portlet" data-id= "6"> <div class="portlet-header"><h6>Heading</h6></div> <div class="portlet-content">First Person</div>

我将jqueryui用于分配数据id的所有portlet。 一个portlet元素的HTML结构如下所示:

 <div class="portlet" data-id= "6">
        <div class="portlet-header"><h6>Heading</h6></div>
        <div class="portlet-content">First Person</div>
        <div class="portlet-content">10</div>
      </div>
$( ".column" ).sortable({
    connectWith: ".column",
    handle: 'h6',
    receive: function(event, ui) {
      console.log(this);
    }
portlet结构驻留在这些div中

现在,当一个portlet从一个列移动到另一个列时,我可以很容易地获得它所在列的
id
,如下所示:

 <div class="portlet" data-id= "6">
        <div class="portlet-header"><h6>Heading</h6></div>
        <div class="portlet-content">First Person</div>
        <div class="portlet-content">10</div>
      </div>
$( ".column" ).sortable({
    connectWith: ".column",
    handle: 'h6',
    receive: function(event, ui) {
      console.log(this);
    }
我只想得到已移动的portlet的
数据id

我怎么能得到这个?
jsiddle是。

移动的元素在传递给
receive
处理程序的
ui
参数的
项中可用,因此您可以编写:

console.log(ui.item.data("id"));

你会发现一个更新的提琴。

谢谢,我是jquery新手,学到了控制台日志以及其他参数(ui、事件)的经验,除此之外,这将提供更好的见解。