angular-bootstrap-datetimepicker icon indicating copy to clipboard operation
angular-bootstrap-datetimepicker copied to clipboard

jQuery error

Open Grigorius opened this issue 12 years ago • 6 comments

I'm getting this error:

TypeError: undefined is not a function

if (configuration.dropdownSelector) {
  jQuery(configuration.dropdownSelector).dropdown('toggle');
}

I changed it to this:

if (configuration.dropdownSelector) {
  jQuery(configuration.dropdownSelector).toggleClass('open');
}

and moved the configuration.dropdownSelector - one element higher (parent element):

<div class="dropdown" id="dtdropdown">
  <a class="dropdown-toggle">
    <div class="input-group">
      <input type="text" class="form-control" ng-model="data.myDate">
      <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
    </div>
  </a>
  <ul class="dropdown-menu">
    <datetimepicker ng-model="data.myDate" datetimepicker-config="{ dropdownSelector: '#dtdropdown' }"/>
  </ul>
</div>

After looking at the code abit:

angular.element(configuration.dropdownSelector).removeClass('open');

This way jQuery is no-longer needed.

Grigorius avatar Nov 05 '14 09:11 Grigorius

Thanks for the info. Can you please create a jsfiddle or plunker that recreates the problem?

dalelotts avatar Nov 05 '14 09:11 dalelotts

http://plnkr.co/edit/mc4eHR1lqJDAFqF8TmY5?p=preview

(open inspect element - then set a time)

TypeError: undefined is not a function
    at Object.dataFactory.setTime (http://run.plnkr.co/JpCsFqLLerb2VEn2/datetimepicker.js:307:54)

I think the issue is that I'm using angular-bootstrap (but removing jQuery-dependency seems like the right way to go):

angular.element(configuration.dropdownSelector).removeClass('open');

Grigorius avatar Nov 05 '14 11:11 Grigorius

Fixed in 0.3.3 - See this fiddle for options when not using jQuery - http://jsfiddle.net/vj8zpmj1/2/

dalelotts avatar Nov 06 '14 04:11 dalelotts

The problem was not using bootstrap.js - but instead using the angular version of it: http://angular-ui.github.io/bootstrap/

Grigorius avatar Nov 11 '14 20:11 Grigorius

Ah, right, I was remembering all of the related issues - I will update the message to also look for bootstrap.js and warn accordingly.

dalelotts avatar Nov 11 '14 21:11 dalelotts

This change is now in the develop branch if you would like to give it a try.

dalelotts avatar Nov 11 '14 22:11 dalelotts