2013-02-25 33 views
1

简化的问题,让我们假设我们使用完全相同的代码比jQuery UI的portlet的部件:jQuery的排序门户+创造充满活力的新的portlet

http://jqueryui.com/sortable/#portlets

我读另一个线程关于计算器话题,但它确实没有给我一个关于如何接近解决方案的线索,因为原来的代码不再avaliable

jQuery How to add a portlet

让想象在S添加一个新的portlet现有列的implest方式:

$("#col0").append($('<div class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" id="p5">' + 
       '<div class="portlet-header ui-widget-header ui-corner-all">' + 
       '<span class="ui-icon ui-icon-minusthick"></span>' + "my title" + '</div>' + 
       '<div class="portlet-content">' + "my content" + '</div></div>')) 

这种方法,我有重要的问题:

  1. 右侧头一角的“+”按钮,不适合工作新的portlet。

  2. 标题和内容文本不保留在div内。当文本达到div的边缘时,它会继续到外面。

  3. 我尝试使用此方法在此计算器中获取portover的顺序。它只适用于使用默认的jquery portlet加载应用程序。

    $(".column").sortable({ 
    
    connectWith: ".column", 
    delay: 150, 
    
    start: function(event, ui) { 
         ui.item.startPos = ui.item.index(); 
         item = ui.item; 
         newList = oldList = ui.item.parent(); 
    }, 
    stop: function(event, ui) { 
         /*saveOrder();*/   
         console.log("Start position: " + ui.item.startPos); 
         console.log("New position: " + ui.item.index()); 
    }, 
    change: function(event,ui) { 
         if(ui.sender) newList = ui.placeholder.parent(); 
    

    },

之前和之后我添加了一个新的portlet,当我试图让排序的列元素:

$("#obtain").button().click(function() { 
     console.log($("#col0").sortable('toArray').toString());}); 

它给了我要素的权数每列(新的一个被添加),但是当我尝试在列之间移动新的列时,当您创建新列时,列中的位置是没有意义的。我认为它就像我应该每次创建一个新的portlet时再次执行start()函数,所以我可以得到正确的索引。但我不知道如何处理它。

非常感谢你为你的时间,我希望我能得到一些建议,

问候

回答

1

#1 我认为你缺少的portlet拨动类

<span class="ui-icon ui-icon-minusthick"> 

应该是

<span class='ui-icon ui-icon-minusthick portlet-toggle'>