mostr / angular-ui-multi-sortable

Angular directive for using jQuery multi-sortable
MIT License
62 stars 13 forks source link

Getting `Cannot call method 'splice' of undefined` on element drop #3

Closed ilyador closed 11 years ago

ilyador commented 11 years ago

I am getting Uncaught TypeError: Cannot call method 'splice' of undefined on line 61

($parse(self.data.destSubset)(model)).splice(self.data.destPosition, 0, ($parse(self.data.origSubset)(model)).splice(self.data.origPosition, 1)[0]);

every time I move and drop an element, amy idea why?

mostr commented 11 years ago

I'll take a look at it in few hours as I'm on my mobile right now. Could you post your code somewhere, so I can take a look in case it is not some obvious bug? Thanks.

ilyador commented 11 years ago

Thanx, you can see it here: http://plnkr.co/edit/wzg7bq0xAkBRoC6LAO88 I get the same error in the console

mostr commented 11 years ago

Thanks for the code. There are two issues here. First (the easy one) is that in model-subset attribute you need to pass "relative" name. So in your example you should replace

<ul ui-multi-sortable ng-model="links" model-subset="links.linkLevel" class="ng-list-level">

with

<ul ui-multi-sortable ng-model="links" model-subset="linkLevel" class="ng-list-level">

After that you can sort top-level elements.

The second issue is more complicated and it has something to do with evaluating Angular expressions. I'll try to narrow it down but I'm not sure if it's gonna work with hierarchical models like this one.

ilyador commented 11 years ago

Thank you, so you think it is better for this project to switch to regular jQuery UI?

mostr commented 11 years ago

I'm not sure. For now I know that when dragging sub-menu items between levels in your example this jQuery sortable plugin seems to emit two completely opposite events.