I recently discovered this code snippet:
$scope.addName = (name) ->
$scope.names.push name
$(".names").draggable
helper: "clone"
revert: true
$(".name-list").droppable
accept: ".names"
activate: ->
$(@).addClass "bordered"
deactivate: ->
$(@).removeClass "bordered"
drop: (e, ui) ->
name = ui.draggable.attr "data-names-name"
$scope.addName name
This piece of code allows users to drag and drop names represented as div
elements onto a list. The name dragged is then added to an array.
However, I encountered an issue where the names array appears empty even after a new name has been successfully pushed into it.