Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Date picker TypeError: setAttribute is not a function setAttribute(scope.$parent, value); #3155

Closed
FDiskas opened this issue Jan 5, 2015 · 12 comments

Comments

@FDiskas
Copy link

FDiskas commented Jan 5, 2015

I got error then datepicker is closed after date is selected
Version: 0.12.0 - 2014-11-16

TypeError: setAttribute is not a function
setAttribute(scope.$parent, value);
@antoinepairet
Copy link

Could you please create a plunkr showing the issue?
thx

@FDiskas
Copy link
Author

FDiskas commented Jan 15, 2015

http://plnkr.co/edit/lSMwdgXmXXu3VA2RQXeI?p=preview
Tried to make date picker on input focus. The error you can see in console.

is-open="focus" ng-focus="focus=true"

@rvanbaalen
Copy link
Contributor

This is still pending. For me, this error occurs when I try to set datepicker-mode:

<input
        type="text"
        class="form-control"
        placeholder="{{ 'LABEL.PLEASE_CHOOSE' | translate }}"
        id="dob"
        name="dob"
        ng-model="relation.dob"
        max-date="datepickerEighteen"
        datepicker-mode="year"
        datepicker-popup="dd-MM-yyyy"
        datepicker-options="dobOptions"
        is-open="dobOpened"
        required
        readonly="readonly">

The above example does not throw the error. That is because the datepicker-mode value is set to year. Datepicker does not read this as a valid value. Therefore I tried 'year' as a value (with the single quotes).

That seems to work in terms of datepicker functionality: the datepicker opens with the year view.

<input
        type="text"
        class="form-control"
        placeholder="{{ 'LABEL.PLEASE_CHOOSE' | translate }}"
        id="dob"
        name="dob"
        ng-model="relation.dob"
        max-date="datepickerEighteen"
        datepicker-mode="'year'" <!-- mind the single quotes here ' ' -->
        datepicker-popup="dd-MM-yyyy"
        datepicker-options="dobOptions"
        is-open="dobOpened"
        required
        readonly="readonly">

But when I have 'year' as a value, it throws the above mentioned error for the function called here on line 494 in datepicker.js

datepickerEighteen is a Date() object with it's year set to current year - 18 to force a minimum age of 18 as a valid input.

I'm using Angular 1.3 with Bootstrap UI 0.12.1

@trueqbit
Copy link

How big are the chances that the fix gets in? It always happens when datepicker-mode is specified as a string literal, whenever you switch the mode browsing the dates.

It's fixable by using a binding, though. So I assume that the correct fix would be to not let the scope watch the value at all, since it's a constant string anyway...

@karianna karianna added this to the 0.13.x milestone Apr 15, 2015
@jafin
Copy link

jafin commented May 3, 2015

Another Plnkr for this, run in angular 1.3.15 and ui-bootstrap-tpls-0.13.0.js http://plnkr.co/edit/QGlIlxgU4SfkQ7oWVOlX?p=preview

@rvanbaalen
Copy link
Contributor

Fix landed in ed10899

@john-jay
Copy link

The fix in 0.13.1 worked for me. Thanks! I am using "triple-quotes" for the mode:

input type="text" ng-model="DOB" datepicker-popup="MM-dd-yyyy" datepicker-mode="'year'" is-open="dobOpen" ng-click="dobOpen = true" />

@uberspeck
Copy link
Contributor

I just updated to ui.bootstrap 1.1.0 and Angular 1.5 and I'm now seeing this issue when i have the mode set to year

@uberspeck
Copy link
Contributor

Here's a plnkr. The error happens whenever you click on anything within the popup...

@icfantv
Copy link
Contributor

icfantv commented Jan 19, 2016

Reopening for investigation.

@zpisgod
Copy link

zpisgod commented Jan 24, 2016

here's a workaround to avoid getting error:
a config option on $scope like this:

$scope.dateOptions = {
        datepickerMode: 'month',
        minMode: 'month'
    };

and then explicit the ‘min-mode', 'datepicker-mode' and 'datepicker-options' property in the html element from the config object defined on $scope like that

<input type="text" class="form-control" uib-datepicker-popup="dd/MM/yyyy" ng-model="today" is-open="calendarOpened" min-mode="dateOptions.minMode" datepicker-mode="dateOptions.datepickerMode" datepicker-options="dateOptions" ng-required="true" close-text="Close" />

@wesleycho wesleycho modified the milestones: 1.1.1, 1.1.2 Jan 25, 2016
@wesleycho wesleycho modified the milestones: 1.1.2, 1.2.0 Feb 1, 2016
@wesleycho wesleycho modified the milestones: 1.2.0, 1.2.1, 1.2.2, 1.3.0 Feb 26, 2016
@wesleycho
Copy link
Contributor

This seems fixed in the 1.2 release - see here for an example.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.