Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dragon-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,17 @@ angular.module('btford.dragon-drop', []).

if (dropArea.length > 0) {
var expression = dropArea.attr('btf-dragon');
var dropCallback = dropArea.attr('btf-dragon-drop');
var targetScope = dropArea.scope();
var match = expression.match(/^\s*(.+)\s+in\s+(.*?)\s*$/);

var targetList = targetScope.$eval(match[2]);
var targetCallback = targetScope.$eval(dropCallback);
targetScope.$apply(function () {
add(targetList, dragValue, dragKey);
if (targetCallback && angular.isFunction(targetCallback)) {
targetCallback(dragValue, dragKey);
}
});
} else if (!dragDuplicate) {
// no dropArea here
Expand Down
5 changes: 4 additions & 1 deletion example.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h3>Things</h3>
</div>
<div class="span6">
<h3>Other Things</h3>
<div btf-dragon="thing in otherThings">{{thing}}</div>
<div btf-dragon="thing in otherThings" btf-dragon-drop="dropCallback">{{thing}}</div>
</div>
</div>

Expand All @@ -53,6 +53,9 @@ <h3>Other Things</h3>
controller('MainCtrl', function ($scope) {
$scope.things = ['one', 'two', 'three'];
$scope.otherThings = [];
$scope.dropCallback = function(value, key) {
console.log('Value:', value, 'Key:', key);
}
});
</script>
</body>
Expand Down