我有一个问题,我找到了一个很棒的脚本,我想用于我的网站,但我不知道如何将它保存到我的数据库,链接here,有人可能指向我的右边方向? 感谢
看看demo。我希望能够对列表进行排序,然后将其保存到我的数据库中。
有一个功能历史,但我无法弄清楚
`var sitemapHistory = {
stack: new Array(),
temp: null,
//takes an element and saves it's position in the sitemap.
//note: doesn't commit the save until commit() is called!
//this is because we might decide to cancel the move
saveState: function(item) {
sitemapHistory.temp = { item: $(item), itemParent: $(item).parent(), itemAfter:
$(item).prev() };
},
commit: function() {
if (sitemapHistory.temp != null) sitemapHistory.stack.push(sitemapHistory.temp);
},
//restores the state of the last moved item.
restoreState: function() {
var h = sitemapHistory.stack.pop();
if (h == null) return;
if (h.itemAfter.length > 0) {
h.itemAfter.after(h.item);
}
else {
h.itemParent.prepend(h.item);
}
//checks the classes on the lists
$('#sitemap li.sm2_liOpen').not(':has(li)').removeClass('sm2_liOpen');
$('#sitemap li:has(ul li):not(.sm2_liClosed)').addClass('sm2_liOpen');
}
}
`
答案 0 :(得分:0)
首先,您需要自己创建HTML格式的站点地图。它必须看起来像页面上的示例:<ul id=”sitemap”> <li> <dl> <dt><a href=”#”>expand/collapse</a> ...
然后从页面中包含脚本并运行它。
不确定这与您的数据库有什么关系。
答案 1 :(得分:0)
可能的解决方案是为每个线元素添加linkID和parentID。然后,当您保存更改时,请在后端对表进行更新。这将涵盖父母/子女的关系。至于排序顺序,我还在考虑这个问题。
有价值的资源是jQuery Sortable文档:http://jqueryui.com/demos/sortable/