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

Date Missing ngModel #449

Closed
Ireisme opened this issue Apr 5, 2016 · 8 comments
Closed

Date Missing ngModel #449

Ireisme opened this issue Apr 5, 2016 · 8 comments

Comments

@Ireisme
Copy link

Ireisme commented Apr 5, 2016

I'm trying to use the editable-bsdate directive with Angular 1.5 and ui-bootstrap 1.2.4, and I'm getting a couple errors involving ngModel.

Specifically you can open up the open the editable-bsdate, select a value and save just fine. After the first time, every subsequent editing of the date causes errors looking for the ngModel controller.

I'm not sure if this directive is somehow changing the uib-datepicker in such a way that the model is removed, or something else entirely.

Here is a plunkr to reproduce the issue: https://plnkr.co/edit/An8NoMhdSdJ1SVIqW2Gp?

@ckosloski
Copy link
Contributor

I do see the uib warnings in the console when I look at your plunkr:

uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead
angular.min.js (line 114)
uib-datepicker initDate attribute usage is deprecated, use datepicker-options attribute instead

Try downloading the latest code and building it yourself. Pull Request #443 added support for a more recent version of ui-bootstrap that I don't think is in the release yet.

@Ireisme
Copy link
Author

Ireisme commented Apr 5, 2016

I thought I saw it in the commits for the 1.11 release, but on a second look you're right and it's not there. I'll give building it locally a shot.

@Ireisme
Copy link
Author

Ireisme commented Apr 6, 2016

I built the latest version of the code locally and added it to the plunkr. Which did remove the warnings, but the same errors are still occurring.

I did a bit of digging and it appears to break specifically on anything past ui-bootstrap version 1.1.0. Taking a look at the commits for that release and it appears that angular-ui/bootstrap#5274 might be causing the issue.

It looks like the ng-model attributes live on the new <div> that is wrapping the calendar control which isn't destroyed when the calendar is closed. Since xeditable is re-creating the uib-datepicker each time it might be that the ng-model stuff is being initialized out of order or something.

Regardless using ui-bootstrap 1.0.3 seems to work fine until the issue is resolved.

@ckosloski
Copy link
Contributor

It does seem like something is not getting removed properly then the editable form is closed. I haven't been able to figure out what the issue is exactly.
I do see that the UibDaypickerController init is being called before the UibDatepickerController init the second time when the error is thrown. It seem like the UibDaypicker is not being cleaned up correctly, but everything I have tried to fix this issue isn't working.
Every time you reopen the calendar, the UibDaypickerController init is called. So on the 3rd open, the UibDaypickerController init is called twice before UibDatepickerController init is called.

@ckosloski
Copy link
Contributor

I think this can be fixed by adding the following to the UibDatepickerPopupController:

$element.on('$destroy', function() {
      $scope.$destroy();
     });

I have opened an issue with ui-bootstrap

@Ireisme
Copy link
Author

Ireisme commented Apr 12, 2016

Thanks @ckosloski! Hopefully ui-bootstrap makes that change.

@ckosloski
Copy link
Contributor

Try using the latest release (0.2.0). It looks like #489 might have fixed the issues.

@ckosloski
Copy link
Contributor

@eugef please close, this should be fixed in the latest release.

@eugef eugef closed this as completed May 15, 2017
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

No branches or pull requests

3 participants