2013-02-25 34 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'>