kandi background
Explore Kits

sortablejs | reorder lists with drag-and-drop | Widget library

 by   SortableJS JavaScript Version: 1.10.2 License: MIT

 by   SortableJS JavaScript Version: 1.10.2 License: MIT

kandi X-RAY | sortablejs Summary

sortablejs is a JavaScript library typically used in User Interface, Widget, jQuery applications. sortablejs has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.
Create and reorder lists with drag-and-drop. For use with modern browsers and touch devices
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • sortablejs has a medium active ecosystem.
  • It has 21483 star(s) with 3154 fork(s). There are 416 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 302 open issues and 1203 have been closed. On average issues are closed in 118 days. There are 11 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of sortablejs is 1.10.2
sortablejs Support
Best in #Widget
Average in #Widget
sortablejs Support
Best in #Widget
Average in #Widget

quality kandi Quality

  • sortablejs has 0 bugs and 0 code smells.
sortablejs Quality
Best in #Widget
Average in #Widget
sortablejs Quality
Best in #Widget
Average in #Widget

securitySecurity

  • sortablejs has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • sortablejs code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
sortablejs Security
Best in #Widget
Average in #Widget
sortablejs Security
Best in #Widget
Average in #Widget

license License

  • sortablejs is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
sortablejs License
Best in #Widget
Average in #Widget
sortablejs License
Best in #Widget
Average in #Widget

buildReuse

  • sortablejs releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Installation instructions, examples and code snippets are available.
  • sortablejs saves you 380 person hours of effort in developing the same functionality from scratch.
  • It has 905 lines of code, 0 functions and 43 files.
  • It has low code complexity. Code complexity directly impacts maintainability of the code.
sortablejs Reuse
Best in #Widget
Average in #Widget
sortablejs Reuse
Best in #Widget
Average in #Widget
Top functions reviewed by kandi - BETA

kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here

Get all kandi verified functions for this library.

Get all kandi verified functions for this library.

sortablejs Key Features

Supports touch devices and modern browsers (including IE9)

Can drag from one list to another or within the same list

CSS animation when moving items

Supports drag handles and selectable text (better than voidberg's html5sortable)

Smart auto-scrolling

Advanced swap detection

Smooth animations

Multi-drag support

Support for CSS transforms

Built using native HTML5 drag and drop API

Supports

Supports any CSS library, e.g. Bootstrap

Simple API

Support for plugins

CDN

No jQuery required (but there is support)

TypeScript definitions via @types/sortablejs

sortablejs Examples and Code Snippets

Community Discussions

Trending Discussions on sortablejs
  • Reorder and preserve php array based on given keys
  • how to get vue draggable moved item
  • Vue.Draggable div items display left and right
  • sortablejs not working within SharePoint (webpart)
  • NPM - why do I get EBADEGINE errors while I meet versions requirements installing reactjs dependancies on docker (buster)?
  • NG_PERSISTENT_BUILD_CACHE=1 ng serve not working
  • find input tag inside a html div and that div is stored in a javascript variable
  • Updating position of SortableJS + Rails Form
  • React-component is not re-rendered when the store is changed, neither automatically nor even by force update
  • Vue draggable. Prevent drop on specific node and allow drop on specific node
Trending Discussions on sortablejs

QUESTION

Reorder and preserve php array based on given keys

Asked 2022-Mar-29 at 12:47

wondering if it's possible to reorder a php array based on given keys, currently I have an array that looks like this:

array:4 [▼
  0 => array:3 [▼
    "to" => "test"
    "name" => "name"
    "type" => "custom"
  ]
  1 => array:4 [▼
    "to" => "test 2"
    "name" => "name 2"
    "type" => "page"
    "target" => "test"
  ]
  2 => array:4 [▼
    "to" => "my link"
    "name" => "something"
    "type" => "custom"
    "target" => "_blank"
  ]
  3 => array:4 [▼
    "to" => "https://github.com/"
    "name" => "github"
    "type" => "custom"
    "target" => "_parent"
  ]
]

On the frontend I'm using sortableJs to allow users to reorder the items to their liking, when the onSort event is fired I collect all of the ids inside of the sortable container and send it to the php function.

the data that sortable send looks like this

array:4 [▼
  0 => "0"
  1 => "2"
  2 => "1"
  3 => "3"
]

Where the value is the order that they're supposed to be in, so based on this data the original array would need to be this

array:4 [▼
  0 => array:3 [▼
    "to" => "test"
    "name" => "name"
    "type" => "custom"
  ]
  2 => array:4 [▼
    "to" => "my link"
    "name" => "something"
    "type" => "custom"
    "target" => "_blank"
  ]
  1 => array:4 [▼
    "to" => "test 2"
    "name" => "name 2"
    "type" => "page"
    "target" => "test"
  ]
  3 => array:4 [▼
    "to" => "https://github.com/"
    "name" => "github"
    "type" => "custom"
    "target" => "_parent"
  ]
]

I've been thinking about this but can't seem to figure it out.

ANSWER

Answered 2022-Mar-29 at 12:43

Oh, I love these! My solution would be

$sorted_array = array_map(
    function($index) use ($original_array){
        return $original_array[$index];
    },
    $sort_order
);

Where $original_array is your original array and $sort_order is the data that sortable sends.

EDIT: This only shuffles the values around, it does not conserve the keys. Your array is not an associative array, and your keys are not in fact keys but indices, and will always be displayed in order.

Source https://stackoverflow.com/questions/71661762

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install sortablejs

Install via command line using yarn or npm.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

Find more information at:

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 650 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

Clone
  • https://github.com/SortableJS/sortablejs.git

  • gh repo clone SortableJS/sortablejs

  • git@github.com:SortableJS/sortablejs.git

Share this Page

share link

See Similar Libraries in

Consider Popular Widget Libraries
Try Top Libraries by SortableJS
Compare Widget Libraries with Highest Support
Compare Widget Libraries with Highest Quality
Compare Widget Libraries with Highest Security
Compare Widget Libraries with Permissive License
Compare Widget Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 650 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit