Search code examples
javascriptjqueryfuelux

Fuelux - setting restrictions after initializing datepicker


I am using fuelux date picker and I have two date pickers on a page. Basically a start date and an end date. What I want to do is initialize both at the beginning and then when the user select a start date then restrict the end date picker to only have date starting from the start date that was selected by the user.

  // Initialize datepickers
  $('#startDate, #endDate').datepicker();

  // When the start date changed by user
  $('#startDate').on('changed.fu.datepicker dateClicked.fu.datepicker', function (evt, startDate) {

    $('#endDate').datepicker('setDate', startDate);
    $('#endDate').datepicker({
       restricted: [{ from: '01/01/1900', to: startDate }]
    });

  });

Right now the set date works but restricted doesn't. Any solution?


Solution

  • You are trying to re-initialize the end date with different options which Fuel UX doesn't support. For your idea to work, you cannot initialize the end date until the start date is set.

    Please review Destruction and re-initialization