I’m new to Javascript and was trying to write a simple function prototype for Dan Grossman’s bootstrap themed dateRangePicker(https://github.com/dangrossman/bootstrap-daterangepicker).
I add the following code to DateRangePicker.prototype
setStartDate: function (startDate) {
alert(startDate);
},
and I create my daterangepicker as follows
var daterange = $('#reportrange').daterangepicker();
but when I call:
daterange.setStartDate(new Date());
I get an error saying that the object doesn’t support the property or method “setStartDate”.
Any help would be much appreciated
Try this:
jQuery plugins return the jQuery object containing the selected elements, for chainability. The actual
DateRangePickerobjects are stored as adataproperty of the selected elements.