ForgeComponents
en

Components

j-Movable

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20

The component handles similar draggable element and supports movement between each other. Each element according to the selector must have defined draggable="true" attribute.


Configuration:

  • selector {String} jQuery selector for watching
  • exec {String} A path to method which will be executed if the user moves element
  • global {Boolean} drag & drop events will be binded to document (default: false)
  • parent {String} selector for finding of element where will be binded drag & drop envets (default: current element)
  • move {Boolean} enables auto re-ordering elements (default: true)
  • container {String} a selector for finding of the main container
  • NEW check {Function(el)} optional, a function for checking of draggability (it must return true or false)

Example of Exec method:

function exec_method(list, dragged, target) {
	// @list jQuery list
}

Good to know:

  • path performs CHANGE()

Use it with <ui-component name="movable">. When the component is not loaded yet, jComponent downloads it on first use from the address in DEF.fallback (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

example.html
<ui-component name="movable" config="selector:.dragme;exec:moved">
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#F0F0F0;text-align:center;position:relative;display:inline-block;margin:10px">A</div>
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#E0E0E0;text-align:center;position:relative;display:inline-block;margin:10px">B</div>
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#D0D0D0;text-align:center;position:relative;display:inline-block;margin:10px">C</div>
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#C0C0C0;text-align:center;position:relative;display:inline-block;margin:10px">D</div>
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#B0B0B0;text-align:center;position:relative;display:inline-block;margin:10px">E</div>
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#A0A0A0;text-align:center;position:relative;display:inline-block;margin:10px">F</div>
</ui-component>

<script>
	function moved(list) {
		console.log(list);
	}
</script>