douting1871 2015-07-10 18:37
浏览 48

如何获取可排序的portlet位置并在移动时更新它?

I am currently working with jQuery UI sortable portlets and PHP, and I need to be able to get the number position where each portlet is and update it when moved.

The portlet in the 1st position should always say Position 1, and the portlet in the 2nd Position should always say Position 2.

The trick is that I want it to update every time that I move a portlet, so that the portlet in the 1st Position is ALWAYS Position 1 and so on. This is because I am moving unique data in these portlets, and the Position value will determine what priority this information is displayed on another page.

So how do I get and display a portlets position on each portlet, and update it whenever it is moved?

<script>
$(function() {
$( ".column" ).sortable({
    connectWith: ".column",
    handle: ".portlet-header",
    cancel: ".portlet-toggle",
    placeholder: "portlet-placeholder ui-corner-all"    
});
$( ".portlet" )
    .addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
    .find( ".portlet-header" )
    .addClass( "ui-widget-header ui-corner-all" )
});
</script>

<?php
for($i = 0; $i < 6; $i++){
?> 
<div class="portlet" id='portlet<?php echo $i; ?>'>

    <div class="portlet-header">
        <div>Position:<span id="value<?php echo $i; ?>"></span></div>
        <script>
             $(document).ready(function() {
                  var portletPosition = $('#portlet<?php echo $i; ?>').sortable("serialize");
                  $("#value<?php echo $i; ?>").html(portletPosition);
             });
        </script>
    </div>

//Unique Portlet data

</div>
<?php
}
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大