Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

Angular event not work as documented

Open simobasso opened this issue 11 years ago • 8 comments

Hi @RubaXa!

I've tried onAdd event callback but evt.item and evt.from not show up.

http://jsfiddle.net/solitary90/m5jq2wcq/

I'm doing wrong?

(I've already tried dev-branch)

simobasso avatar Mar 24 '15 17:03 simobasso

I've got the same issue, you can fix it by adding keys in the object in the _emitEvent() function in ng-sortable.js.

So the old one (line 80 from ng-sortable.js)

options[name] && options[name]({
  model: item,
  models: source && source.items(),
  oldIndex: evt.oldIndex,
  newIndex: evt.newIndex
});

and the new one

options[name] && options[name]({
  model: item,
  models: source && source.items(),
  oldIndex: evt.oldIndex,
  newIndex: evt.newIndex,
  from : evt.from,
  item : evt.item
});

.from works great but it seems tha .item is a copy of the item and not the original one

yohankoehler avatar Mar 25 '15 15:03 yohankoehler

Because: https://github.com/RubaXa/Sortable/blob/master/ng-sortable.js#L18-L24

RubaXa avatar Mar 25 '15 15:03 RubaXa

@yohankoehler Working with DOM elements is not Angular way.

RubaXa avatar Mar 25 '15 15:03 RubaXa

@RubaXa You are in a directive.

yohankoehler avatar Mar 25 '15 15:03 yohankoehler

@yohankoehler So what? Your commit are forwarding DOM elements from directive to outside.

RubaXa avatar Mar 25 '15 15:03 RubaXa

@RubaXa my bad, sorry please forget this commit !!!.

@Raiseupcreativity So I guess you will have to deal with the onRemove event to retrieve the model that the item is comming from.

yohankoehler avatar Mar 25 '15 15:03 yohankoehler

@yohankoehler Already forgotten :see_no_evil:

RubaXa avatar Mar 25 '15 15:03 RubaXa

yes but I've need access on drag-over target, but i've made another directive for that....

simobasso avatar Mar 26 '15 10:03 simobasso