angular-ui / ui-date

jQuery UI Datepicker for AngularJS
http://angular-ui.github.io/ui-date/
MIT License
266 stars 207 forks source link

Angular 1.1.4 causes uiDatepicker to return TypeError #6

Closed DServy closed 8 years ago

DServy commented 11 years ago

For those upgrading to 1.1.4

uiDatepicker throws a TypeError when switching between routed templates without a datepicker element in it. Works fine in 1.1.3, so its probably something related to https://github.com/angular/angular.js/commit/fe8d893b839e9b14e3e55a3a0523cc1e6355bdd5 that added feature.

Console logging right before the element.datepicker('destroy'); seems to show that the directive is called again when switching between routed templates, however, in Angular versions < 1.1.4 this behavior is not noticed. You can see http://localhost/urlhere#!/188/1/tna:755:50 is the new template that is trying to render, however this template has no datepicker methods on it.

Full error below:

TypeError: Cannot read property 'append' of undefined
    at Datepicker.$.extend._destroyDatepicker (https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js:5:135207)
    at HTMLInputElement.<anonymous> (https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js:5:163892)
    at Function.e.extend.each (https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js:2:11776)
    at e.fn.e.each (https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js:2:8304)
    at $.fn.datepicker (https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js:5:163824)
    at Object.initDateWidget (http://localhost.share/js/base/angular/angular-ui.js:304:17)
    at Object.applyFunction [as fn] (http://localhost.share/profiles#!/188/1/tna:755:50)
    at Object.e.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js:89:356)
    at Object.$delegate.__proto__.$digest (http://localhost/urlhere#!/188/1/tna:820:31)
    at Object.e.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js:91:431) 
petebacondarwin commented 9 years ago

I'm not going to have time to deal with this - and it is probably out of date anyway. Sorry.

alexanderchan commented 8 years ago

datepicker currently works with newer versions of angular 1.3+