javascript-jQuery手风琴列中的Slickgrid无法正确显示
作者:互联网
我在jQuery手风琴中使用slickgrid,每当页面刷新和手风琴展开时,网格内的列都将混乱并破坏.我尝试使用
grid.resizeCanvas();
在我的手风琴内无济于事.
这是我的代码.
var grid = (grid1, grid2, grid3);
$('#accordion').accordion({
collapsible: true,
beforeActivate: function (event, ui) {
grid.resizeCanvas();
// The accordion believes a panel is being opened
if (ui.newHeader[0]) {
var currHeader = ui.newHeader;
var currContent = currHeader.next('.ui-accordion-content');
// The accordion believes a panel is being closed
} else {
var currHeader = ui.oldHeader;
var currContent = currHeader.next('.ui-accordion-content');
}
// Since we've changed the default behavior, this detects the actual status
var isPanelSelected = currHeader.attr('aria-selected') == 'true';
// Toggle the panel's header
currHeader.toggleClass('ui-corner-all', isPanelSelected).toggleClass('accordion-header-active ui-state-active ui-corner-top', !isPanelSelected).attr('aria-selected', ((!isPanelSelected).toString()));
// Toggle the panel's icon
currHeader.children('.ui-icon').toggleClass('ui-icon-triangle-1-e', isPanelSelected).toggleClass('ui-icon-triangle-1-s', !isPanelSelected);
// Toggle the panel's content
currContent.toggleClass('accordion-content-active', !isPanelSelected)
if (isPanelSelected) { currContent.slideUp(); } else { currContent.slideDown(); }
return false; // Cancels the default action
}
});
更新资料
我尝试使用
var grid = [grid1, grid2, grid3];
$("#accordion").accordion({
afterActivate: function (event, ui) {
grid[0].resizeCanvas();
}
});
不幸的是,这也没有奏效.
解决方法:
我使用window.location.reload()并且重新加载页面时,网格列按预期对齐.我尝试在递归方法调用中执行此操作,而不是重新加载页面,但遇到了您描述的问题.
如果您可以刷新页面而不是进行递归调用,则可以解决问题.
标签:slickgrid,javascript,jquery 来源: https://codeday.me/bug/20191028/1952057.html