admin管理员组文章数量:1391929
I am having trouble to change my sortablejs settings after its set.
The initialization of this function is done within an other script(this script may not change) and is done when the page is loaded.
what i have for code in other script is the following:
//initialize sortable
function initSortable() {
$(".menu-item-list").each(function (index) {
var id = this.id;
var options = {
animation: 150,
group: "menu-item-list",
chosenClass: "sortable-chosen",
ghostClass: "sortable-ghost",
filter: ".empty-area-text",
cancel: ".empty-area-text",
onAdd: function (e) {
//moved to the new column. save the items position
saveItemsPosition();
removeEmptyAreaText(e.to);
addEmptyAreaText(e.from);
adjustHeightOfItemsContainer();
removeSubmenuClass(e.item, e.to);
},
onUpdate: function (e) {
//moved to the same column. save the items position
saveItemsPosition();
adjustHeightOfItemsContainer();
removeSubmenuClass("", "");
}
};
Sortable.create($("#" + id)[0], options);
});
}
I am having trouble to change my sortablejs settings after its set.
The initialization of this function is done within an other script(this script may not change) and is done when the page is loaded.
what i have for code in other script is the following:
//initialize sortable
function initSortable() {
$(".menu-item-list").each(function (index) {
var id = this.id;
var options = {
animation: 150,
group: "menu-item-list",
chosenClass: "sortable-chosen",
ghostClass: "sortable-ghost",
filter: ".empty-area-text",
cancel: ".empty-area-text",
onAdd: function (e) {
//moved to the new column. save the items position
saveItemsPosition();
removeEmptyAreaText(e.to);
addEmptyAreaText(e.from);
adjustHeightOfItemsContainer();
removeSubmenuClass(e.item, e.to);
},
onUpdate: function (e) {
//moved to the same column. save the items position
saveItemsPosition();
adjustHeightOfItemsContainer();
removeSubmenuClass("", "");
}
};
Sortable.create($("#" + id)[0], options);
});
}
Share
Improve this question
asked Mar 13 at 8:55
oelimoeoelimoe
4212 silver badges11 bronze badges
1 Answer
Reset to default 0To make it so that you can change the settings is by using
setTimeout(() => { // timeout is important
$(".menu-item-list").each(function() {
let instance = Sortable.get(this); // Get existing Sortable instance
if (instance) {
// Apply the updated filter setting
instance.option("multiDrag", true);
instance.option("selectedClass", "selected");
instance.option("fallbackTolerance", 3);
}
});
}, 500);
本文标签: javascriptChange the settings of Sortablejs after its setStack Overflow
版权声明:本文标题:javascript - Change the settings of Sortablejs after its set - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744712789a2621224.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论