我正在使用Gridster插件(http://gridster.net)。我在Github上發現了一個可更改大小的更新演示。我還添加了jQuery livequery插件,以便與未來的項目保持一致。jQuery Dragable和Resizable衝突
添加新的網格項後,draglable/resizable工作正常。默認項目工作正常,只有新項目的問題。這是我如何使用代碼:
調整大小並拖動
var layout;
var grid_size = 30;
var grid_margin =5;
$(function() {
layout = $('.layouts_grid ul').gridster({
widget_margins: [grid_margin, grid_margin],
widget_base_dimensions: [grid_size, grid_size],
serialize_params: function($w, wgd) {
return {
x: wgd.col,
y: wgd.row,
width: wgd.size_x,
height: wgd.size_y,
id: $($w).attr('data-id'),
name: $($w).find('.block_name').html(),
};
},
min_rows: block_params.max_height
}).data('gridster');
$('.layout_block').livequery(function(){
$('.layout_block').resizable({
grid: [grid_size + (grid_margin * 2), grid_size + (grid_margin * 2)],
animate: false,
minWidth: grid_size,
minHeight: grid_size,
containment: '#layouts_grid ul',
autoHide: true,
stop: function(event, ui) {
var resized = $(this);
setTimeout(function() {
resizeBlock(resized);
}, 300);
}
});
});
//This works only for default items
$('.ui-resizable-handle').hover(function() {
layout.disable();
}, function() {
layout.enable();
});
});
添加項目
$('#add').click(function(){
var tmpP = '<li class="layout_block new ui-resizable ui-resizable-autohide" style="background-color: #B60000;">New one</li>'
var gridster = $(".layouts_grid ul").gridster().data('gridster');
gridster.add_widget(tmpP, 2, 1);
});
請檢查的jsfiddle以及http://jsfiddle.net/PrtrR/51/
請幫助我這樣做。
問候。
感謝隊友,我會看看這個 – user1915190 2013-09-16 06:32:07