angular-ui / ui-sortable

jQuery UI Sortable for AngularJS
http://angular-ui.github.io/ui-sortable/
MIT License
1.26k stars 444 forks source link

Question about undocumented events (ui-sortable:moved) #539

Open sneakyfildy opened 6 years ago

sneakyfildy commented 6 years ago

Hi. Why events like ui-sortable:moved are not documented. The callbacks you suggest to use are called without any arguments (or I can't get how to have them).

ui-sortable-stop="u.onDrop($event, ui)" doesn't bring any arguments into onDrop handler function. I've tried to inspect sources and didn't find any arguments insertion (except some "locals").

So. What are these undocumented events for and why "ui" arguments is not given into a callback function. Thank you.

thgreasi commented 6 years ago

Regarding point 1, these events were contributed but I forgot to also open an issue regarding the docs. PRs are welcome.

Regarding point 2, I think that it gets passed and we also have a test case for that,

sneakyfildy commented 6 years ago

Thank you very much. Confirming arguments are sent correctly. My handler setting was incorrect This one is good ui-sortable-stop="u.onDrop"

sneakyfildy commented 6 years ago

Erm. Is there a way to attach a context to this handler?

Oh yes, sure! Just use sortable options object and make a binding inside:

opts = {
    stop: this.onDrop.bind(this)
}
thgreasi commented 6 years ago

👍