How to use the sortablejs.create function in sortablejs

To help you get started, we’ve selected a few sortablejs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SpatialTranscriptomicsResearch / st_spot_detector / client / src / app / aligner.directive.js View on Github external
}
                return ret;
            };

            // make layer list sortable
            sortable.create(element[0].querySelector('#layer-list'), {
                onSort() {
                    // update layer order
                    _.each(this.toArray(), (val, i) => {
                        scope.layers.layerOrder[i] = val;
                    });
                },
            });

            // make adjustments sortable
            sortable.create(element[0].querySelector('#adjustment-list'), {
                onSort({ oldIndex, newIndex }) {
                    const adjustments = scope.state.adjustments.get(scope.state.active);
                    const adjustment = adjustments.splice(oldIndex, 1)[0];
                    adjustments.splice(newIndex, 0, adjustment);
                    scope.applyState();
                },
                handle: '.sort-handle',
            });
        },
        restrict: 'E',
github dotnetcore / WTM / demo / WalkingTec.Mvvm.VueDemo / ClientApp / src / components / frame / DraggableSelect / index.vue View on Github external
private setSort() {
        const draggableSelect = this.$refs.draggableSelect as Select;
        const el = draggableSelect.$el.querySelectorAll(
            ".el-select__tags > span"
        )[0] as HTMLElement;
        this.sortable = Sortable.create(el, {
            ghostClass: "sortable-ghost", // Class name for the drop placeholder
            onEnd: evt => {
                if (
                    typeof evt.oldIndex !== "undefined" &&
                    typeof evt.newIndex !== "undefined"
                ) {
                    const targetRow = this.value.splice(evt.oldIndex, 1)[0];
                    this.value.splice(evt.newIndex, 0, targetRow);
                }
            }
        });
    }
}
github tuandm / laravue / resources / js / views / table / DragTable.vue View on Github external
setSort() {
      const el = this.$refs.dragTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0];
      this.sortable = Sortable.create(el, {
        ghostClass: 'sortable-ghost', // Class name for the drop placeholder,
        setData: function(dataTransfer) {
          // to avoid Firefox bug
          // Detail see : https://github.com/RubaXa/Sortable/issues/1012
          dataTransfer.setData('Text', '');
        },
        onEnd: evt => {
          const targetRow = this.list.splice(evt.oldIndex, 1)[0];
          this.list.splice(evt.newIndex, 0, targetRow);

          // for show the changes, you can delete in you code
          const tempIndex = this.newList.splice(evt.oldIndex, 1)[0];
          this.newList.splice(evt.newIndex, 0, tempIndex);
        },
      });
    },
github michelmansour / virgil / client / src / PoemListContainer.jsx View on Github external
componentDidMount = () => {
    this.loadPoems();
    this.state.intervalId = setInterval(this.loadPoems, this.props.route.pollInterval);
    const el = document.getElementById('mainPoemList');
    Sortable.create(el, {
      onUpdate: (evt) => {
        const reordering = this.state.data.slice();
        const movedPoem = reordering.splice(evt.oldIndex, 1);
        reordering.splice(evt.newIndex, 0, ...movedPoem);
        this.setState({ data: reordering });
        this.savePoems();
      },
    });
  }
github codice / ddf / catalog / ui / catalog-ui-search / src / main / webapp / component / attributes-rearrange / attributes-rearrange.view.js View on Github external
onRender: function () {
        Sortable.create(this.el, {
            onEnd: () => {
                this.handleSave();
            }
        });
    },
    handleSave: function () {
github dongdong-cloud / dd-admin / src / views / basic / table.vue View on Github external
this.$nextTick(() => {
        let xTable = this.$refs.xTable1;
        Sortable.create(
          xTable.$el.querySelector(".body--wrapper>.vxe-table--body tbody"),
          {
            handle: ".drag-btn",
            onEnd: ({ newIndex, oldIndex }) => {
              let currRow = this.tableData.splice(oldIndex, 1)[0];
              this.tableData.splice(newIndex, 0, currRow);
            }
          }
        );
      });
    },
github girder / girder / plugins / ldap / girder_ldap / web_client / views / ConfigView.js View on Github external
render: function () {
        this.$el.html(template({
            servers: this.servers
        }));

        this.breadcrumb.setElement(this.$('.g-config-breadcrumb-container')).render();
        sortable.create(this.$('.g-ldap-server-accordion')[0], {
            filter: 'input',
            preventOnFilter: false
        });
        return this;
    },
github wilfriedE / LearnIt / app / javascript / packs / sortable_collection_items.js View on Github external
var ready = () => {
  var update_positions = function (el){
    $(el).children('.collection_item').each(function (i) {
      var position_input = $(this).find('input.collection_item_position');
      position_input.val(i);
    });
  }

  var form_el = document.getElementById('collectibles');
  window.CollectionItems = Sortable.create(form_el, {
    animation: 150,
    ghostClass: 'ghost',
    sort: true
  });

  $("body").on('DOMSubtreeModified', "#collectibles", function(evt) {
      update_positions(evt.target);
  });

  $(".remove-field").on('click', function(evt) {
    var field_id = $(evt.target).data("field-id");
    $("#" + field_id).remove();
  });
}
github react-photonkit / react-photonkit / src / list-group.jsx View on Github external
_node(n) {
		if (n) {
			this.node = n;
			this.sortable = Sortable.create(n, {
				handle: '.list-group',
				disabled: !this.props.draggable
			});
		}
	}
github reactioncommerce / reaction / imports / plugins / included / product-variant / client / templates / products / productGrid / productGrid.js View on Github external
Template.productGrid.onRendered(function () {
  const instance = this;

  if (Reaction.hasPermission("createProduct")) {
    const productSort = $(".product-grid-list")[0];

    this.sortable = Sortable.create(productSort, {
      group: "products",
      handle: ".product-grid-item",
      onUpdate() {
        const tag = ReactionProduct.getTag();

        instance.$(".product-grid-item")
          .toArray()
          .map((element, index) => {
            const productId = element.getAttribute("id");
            const position = {
              position: index,
              updatedAt: new Date()
            };

            Meteor.call("products/updateProductPosition", productId, position, tag,
              error => {

sortablejs

JavaScript library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery required. Supports Meteor, AngularJS, React, Polymer, Vue, Knockout and any CSS library, e.g. Bootstrap.

MIT
Latest version published 4 months ago

Package Health Score

94 / 100
Full package analysis