如何通过单击按钮

时间:2015-05-14 09:39:33

标签: javascript jquery-plugins packery

我正在尝试使用packery jquery插入我的项目。一切正常,但我只需要在右上角点击最小化按钮时删除包装。我怎么能这样做,请帮助我的朋友。

这是我的代码

<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 code

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();
      });
    }
  };
}]);

感谢

1 个答案:

答案 0 :(得分:0)

你可能想要destroy方法。