我希望能够删除专辑内容从我的div时,按下一个按钮。类似于$("#myDiv").html(""),因此库将从DOM中删除,然后我可以在同一个div中重新创建库,但单击另一个按钮时可以使用不同的数据源数组。
现在,我有一个创建nanoGallery的函数,当用户单击按钮时调用它,然后当用户单击另一个按钮时,我需要删除nanoGallery并用不同的数据重新创建它。
现在不起作用的代码:
function createAlbum()
{
// This object has a different array every time button is clicked!
var pics = currentOrder["vehicle-pictures"];
$("#repairPictures").nanoGallery({
items : pics,
colorSchemeViewer : 'light',
photoset : 'none',
viewerDisplayLogo : true,
thumbnailLazyLoad : true,
thumbnailLabel : { display: true, position: 'overImageOnBottom', titleMaxLength: 35 },
colorScheme : { thumbnail:{ labelBackground: '#444 !important' } },
locationHash : false,
thumbnailHoverEffect :'borderLighter,imageScaleIn80'
});
}然后移除它..。
//---------------------------------------------------------------------
function cleanAlbum()
{
$("#repairPictures").html("");
}我怎样才能做到这一点?
顺便说一句,$("#myDiv").html("")方法只是一个例子,如果您知道从div中删除html库的更好方法,请随时提出建议。
发布于 2016-11-01 23:24:05
如果要从DOM中删除相册,请使用:$('#yourElement').nanoGallery('destroy');,但可以为nanoGallery设置新项,只需执行$('#yourElement').nanoGallery('reload');
https://stackoverflow.com/questions/40369525
复制相似问题