The problem of choosing daterange: rp.find ('. Range-end'). datepicker ('getDate') returns null

SCENARIO

A very simple instance of daterangepicker:

<div class="section"> <label for="drp">date-range-picker</label> <input type="text" id="drp" /> <script> (function(){ $('#drp').daterangepicker({ presetRanges: [ { text: 'Last 30 days', dateStart: function () { return Date.parse('today').add({day: -30}) }, dateEnd: function () { return Date.parse('today').add({day: -1}); } }, { text: 'Previous month' , dateStart: function () { return Date.today().add({month:-1}).moveToFirstDayOfMonth()} , dateEnd: function () { return Date.today().add({month:-1}).moveToLastDayOfMonth(); } }, { text: 'Current month' , dateStart: function () { return Date.today().moveToFirstDayOfMonth()} , dateEnd: function () { return Date.today().add({day:-1}); } } ], presets: {dateRange: 'Select range'}, rangeStartTitle: 'Start date', rangeEndTitle: 'End date', doneButtonText: 'Done', prevLinkText: 'Prev', nextLinkText: 'Next', rangeSplitter: ' - ', dateFormat: "dd/mm/yy", closeOnSelect: true }); })(); </script> </div> 

Includes:

 <script type="text/javascript" language ="javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script type="text/javascript" language ="javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script> <script type="text/javascript" language ="javascript" src="client/date.js"></script> <script type="text/javascript" language ="javascript" src="client/daterangepicker/daterangepicker.jQuery.js"></script> 

Question

In local env everything works correctly. In the working environment, the following error occurs after selecting any preset:

 Uncaught TypeError: Cannot call method 'getDate' of null @daterangepicker.jQuery.js:162 

The error occurs due to the following statements being executed:

var range_end = rp.find ('. range-end'); [...] var rangeB = fDate (range_end.datepicker ('getDate'));

I am angry. It seems that daterangepicker is not initializing the datepicker in an element of the .range-end class. But I can’t understand what’s wrong.

There are no errors in the console (Chrome).

References

+4
source share
1 answer

Can you provide js fiddle. Actually, I cannot add a comment to your question, so I have to write this as an answer.

0
source

All Articles