Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with angular 1.3-beta #120

Closed
antoinepairet opened this issue Jul 18, 2014 · 10 comments
Closed

Not compatible with angular 1.3-beta #120

antoinepairet opened this issue Jul 18, 2014 · 10 comments

Comments

@antoinepairet
Copy link

Using
angular 1.3-beta.15
jQuery 2.1.1
jQueryUI 1.9.1
ngDragDrop 1.0.7

Loading the page and using the drag-drop feature is not an issue until a route change is performed. The following error is fired:

Error: cannot call methods on draggable prior to initialization; attempted to call method 'destroy':

Error: cannot call methods on draggable prior to initialization; attempted to call method 'destroy'
at Function.jQuery.extend.error (http://localhost:9000/bower_components/jquery/dist/jquery.js:250:9)
at HTMLDivElement. (http://localhost:9000/bower_components/jquery-ui/ui/jquery-ui.js:487:15)
at Function.jQuery.extend.each (http://localhost:9000/bower_components/jquery/dist/jquery.js:375:23)
at jQuery.fn.jQuery.each (http://localhost:9000/bower_components/jquery/dist/jquery.js:139:17)
at $.fn.(anonymous function) as draggable
at HTMLDivElement. (http://localhost:9000/bower_components/angular-dragdrop/src/angular-dragdrop.js:278:19)
at HTMLDivElement.jQuery.event.dispatch (http://localhost:9000/bower_components/jquery/dist/jquery.js:4409:9)
at HTMLDivElement.elemData.handle (http://localhost:9000/bower_components/jquery/dist/jquery.js:4095:28)
at Object.jQuery.event.trigger (http://localhost:9000/bower_components/jquery/dist/jquery.js:4324:12)
at jQuery.fn.extend.triggerHandler (http://localhost:9000/bower_components/jquery/dist/jquery.js:4881:24) angular.js:10264
(anonymous function) angular.js:10264
(anonymous function) angular.js:7506
Scope.$digest angular.js:12654
Scope.$apply angular.js:12873
(anonymous function) angular.js:10052
jQuery.event.dispatch jquery.js:4409
elemData.handle jquery.js:4095

@laplantb
Copy link

also not compatible with angular 1.3.rc-3

@theblang
Copy link

@codef0rmer , any plans to become 1.3 compatible?

@neilhem
Copy link

neilhem commented Sep 29, 2014

👍 for Angularjs 1.3 compatibility

@codef0rmer
Copy link
Owner

Does anybody have a demo to state a problem? For me, it works even with 1.3+

@laplantb
Copy link

laplantb commented Oct 1, 2014

I found the cause : inserting the script jquery.ui.js after angular.js cause the issue in 1.3 but not 1.2. Specially if the drag or drop directive is used with ngRepeat. On removing the element by $animate.leave , the drag or drop plugin get destroyed by the 'remove' event before the $destroy event.

Play way this forked Demo: http://plnkr.co/edit/uiwZhsSmdtDebB4ZaRWT

@codef0rmer
Copy link
Owner

@laplantb: This was even existed for 1.2 when routing is in action. However, I'm not sure if that's angular's version issue. Today I fixed the similar issue with an hack and probably release a new version soon.

@laplantb
Copy link

laplantb commented Oct 1, 2014

I was using this hack :

element.on('$destroy', function() {
if(element.data('droppable')){
element.droppable('destroy');
}
});

@codef0rmer
Copy link
Owner

@laplantb: This element.data('draggable') always returns undefined for me even if draggable was initialized.

@laplantb
Copy link

laplantb commented Oct 1, 2014

Sorry I used the same logic as jqueryui before it throws the exception (look around line 507 of jqueryui.js (1,11,1)). I assumed $.data is used for public access but was wrong. If you look at line 502, element.draggable('instance') would return the instance. I dunno if it works with old versions of jqueryui though.

@codef0rmer
Copy link
Owner

@laplantb: I noticed that the draggable/droppable was initialized but still throwing the error on destroy. That's why I call it a hack :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants