Skip to content

Instantly share code, notes, and snippets.

@beautyfree
Created December 23, 2013 17:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save beautyfree/8100916 to your computer and use it in GitHub Desktop.
###
Thanks to:
http://stackoverflow.com/a/9649638/1024097
###
class Instruction
constructor: ->
@initEvents()
initEvents: ->
$("#steps_fields").sortable
items: ".fields"
dropOnEmpty: true
cursor: "move"
# handle: ".move"
opacity: 0.4
scroll: true
axis: "y"
placeholder: "ui-state-highlight"
start: (e, ui) ->
ui.placeholder.height ui.item.height()
update: ->
$(@).find(".fields").each (index) ->
$(@).find("input.step_position").val index + 1
$ ->
@Instruction = new Instruction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment