2015-05-14 92 views
0

我想在我的項目中使用packery jquery pluging。一切工作正常,但我需要刪除打包只有當我點擊右上角的最小化按鈕。我怎麼能做到這一點,請幫助我的朋友。如何通過點擊按鈕刪除packery

這裏是我的代碼

<div class="packery" > 
<div class="module-sizer"></div> 
    <div class="gutter-sizer"></div> 
    <div class="module"> 
    <remove headertitle="Mine"></remove> 
    </div> 
    <div class="module" > 
    <remove headertitle="team lead"></remove> 
    </div> 
</div> 

js代碼

app.directive('packery', ['$rootScope', function($rootScope) { 
    return { 
    constrain: 'A', 
    link: function(scope, element, attrs) { 
     element.ready(function() { 
     var packery = new Packery(element[0], { 
      rowHeight: '.module-sizer', 
      itemSelector: '.module', 
      columnWidth: '.module-sizer' 
     }); 

     //this part is for remove 
     //this should be done only on button click 
     var packerys = $('.packery').packery(); 

     packerys.on('click', function(event) { 
      packerys.packery('remove', event.target); 
      packerys.packery(); 
     }); 

     angular.forEach(packery.getItemElements(), function(item) { 
      var draggable = new Draggabilly(item); 

      packery.bindDraggabillyEvents(draggable); 
     }); 
     packery.layout(); 
     }); 
    } 
    }; 
}]); 

感謝

+0

請提供您的代碼,您使用jquery或vanilla js? – daremachine

+0

感謝您的回覆,我使用jquery – stackoverflow

+0

請提供您的代碼。你已經試過 – vel

回答

0

你可能想destroy方法。

+0

感謝您的回覆,但我需要通過點擊 – stackoverflow

+0

確定刪除特定的包裝,然後點擊TOOGLE Packery BUTTON http://codepen.io/desandro/pen/kEjed – daremachine