jquery sortable on div drag and drop

Solutions on MaxInterview for jquery sortable on div drag and drop by the best coders in the world

showing results for - "jquery sortable on div drag and drop"
Martina
25 Jan 2019
1var oldContainer;
2$("ol.nested_with_switch").sortable({
3  group: 'nested',
4  afterMove: function (placeholder, container) {
5    if(oldContainer != container){
6      if(oldContainer)
7        oldContainer.el.removeClass("active");
8      container.el.addClass("active");
9
10      oldContainer = container;
11    }
12  },
13  onDrop: function ($item, container, _super) {
14    container.el.removeClass("active");
15    _super($item, container);
16  }
17});
18
19$(".switch-container").on("click", ".switch", function  (e) {
20  var method = $(this).hasClass("active") ? "enable" : "disable";
21  $(e.delegateTarget).next().sortable(method);
22});