Datepicker - Uncaught TypeError: Cannot read property 'apply' of undefined

  • 1
  • Problem
  • Updated 3 years ago
  • Not a Problem
I want to ensure that the user does not select an end date before the start date.  In this scenario, both dates will already be populated (editing an existing row in a calendar pop-up).

I'm using the approach outlined here to use a custom field renderer to override a datepicker:
https://community.skuid.com/skuid/topics/override_the_standard_date_picker?topic-reply-list%5Bsettings%5D%5Bfilter_by%5D=all

Specifically the minDate attribute as discussed here:https://community.skuid.com/skuid/topics/how-to-disable-the-dates-in-datepicker

Here is the code for the custom field renderer:

var field = arguments[0],    sdate = arguments[0].row.Start_Date__c; //datetime field
    value = arguments[1],
    $ = skuid.$;
skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
//convert to js date
var jsStartDate = skuid.time.parseSFDate(sdate);
console.log(jsStartDate);
if (field.mode==='edit'){
   var dateInput = field.element.find('input.hasDatepicker');
   dateInput.datepicker( "minDate", jsStartDate, true);
   dateInput.datepicker("refresh");
}
The pop-up fails to display, and I get this error:Uncaught TypeError: Cannot read property 'apply' of undefined

I've searched this error, but cannot find anything applicable to this approach of modifying the datepicker.
Photo of Jared Jones

Jared Jones

  • 2,214 Points 2k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Jared Jones

Jared Jones

  • 2,214 Points 2k badge 2x thumb
Figured it out.  I had dropped one of the parameters.  minDate should be set like this:
...
dateInput.datepicker( "option", "minDate", jsStartDate);
...