Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9005495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:09:35+00:00 2026-06-16T01:09:35+00:00

I have a verry complex datepicker in a div that reload’s with AJAX after

  • 0

I have a verry complex datepicker in a div that reload’s with AJAX after a submit, but after the submit (and AJAX reload of the page) the datepicker is not working anymore.

Datepicker code:

        dates[x] = $( "#from_"+x+", #to_"+x ).datepicker({ 
        dateFormat: "dd-mm-yy",
        numberOfMonths: 3,
        showWeek: true,
        maxDate: max_date_ini,
        minDate: min_date_ini, 
        beforeShow:function legen_array() {
            var from_of_to = this.id.indexOf("from_") != -1 ? "from" : "to";
            //eerst een check of er niet nog een datepicker periode half gevuld is (want dan is overlap mogelijk)
            if (periode_half_gevuld != x && periode_half_gevuld != 0){
                alert('Er is nog een periode niet geheel ingevuld, er is alleen een vanaf of alleen een tot datum ingevuld. Maak deze periode eerst compleet of maak hem leeg door op verwijderen te klikken');
                return false;           
            }
            var date_from_open = $("#from_"+x).val();
            var date_to_open = $("#to_"+x).val();
            var timestamp_from_open = Date.UTC(date_from_open.substring(6,10),date_from_open.substring(3,5)-1,date_from_open.substring(0,2))/1000;
            var timestamp_from_open_teller = Date.UTC(date_from_open.substring(6,10),date_from_open.substring(3,5)-1,date_from_open.substring(0,2))/1000;
            var timestamp_to_open = Date.UTC(date_to_open.substring(6,10),date_to_open.substring(3,5)-1,date_to_open.substring(0,2))/1000;
            //als from en to gevuld zijn dan eerst deze waardes uit array halen (Anders kan 1 dag verder of terug niet gekozen worden)
            if (timestamp_from_open > 0 && timestamp_to_open > 0){
                geselecteerde_vanaf_datums.splice( $.inArray(timestamp_from_open,geselecteerde_vanaf_datums), 1 );
                geselecteerde_tot_datums.splice( $.inArray(timestamp_to_open,geselecteerde_tot_datums), 1 );
                while (timestamp_from_open_teller <= (timestamp_to_open+1)){
                    datums_niet_beschikbaar.splice( $.inArray(timestamp_from_open_teller,datums_niet_beschikbaar), 1 );
                    timestamp_from_open_teller = timestamp_from_open_teller + 86400;                    
                }
                if (this.id.indexOf("from_") == 0 && $("#to_"+x).val() != '' && geselecteerde_tot_datums.length >= 1){
                    var min_datum = new Date (getNextMinVal(geselecteerde_tot_datums, timestamp_to_open)*1000);
                    $('#from_'+x).datepicker('option', {minDate: min_datum,maxDate: $("#to_"+x).val()});
                }
                else if (this.id.indexOf("from_") == 0 && $("#to_"+x).val() != '' && geselecteerde_tot_datums.length == 0){
                    $('#from_'+x).datepicker('option', {minDate: new Date(volgend_jaar, 1 - 1,1),maxDate: $("#to_"+x).val()});
                }
                else if (this.id.indexOf("from_") == -1 && $("#from_"+x).val() != '' && geselecteerde_vanaf_datums.length >= 1){
                    var max_datum = new Date (getNextMaxVal(geselecteerde_vanaf_datums, timestamp_from_open)*1000);
                    $('#'+this.id).datepicker('option', {minDate:$("#from_"+x).val(),maxDate: max_datum});
                }
                else if (this.id.indexOf("from_") == -1 && $("#from_"+x).val() != '' && geselecteerde_vanaf_datums.length == 0){
                    $('#to_'+x).datepicker('option', {minDate: $("#from_"+x).val(),maxDate: new Date(volgend_jaar, 12,0)});
                }
                else {alert('10');}
            }
            else if(timestamp_from_open > 0 && timestamp_to_open < 0 && from_of_to == 'to' && geselecteerde_vanaf_datums.length >= 1){
                var closest_max = getNextMaxVal(geselecteerde_vanaf_datums, timestamp_from_open);
                $("#"+this.id).datepicker('option', {maxDate: new Date(closest_max*1000)});
                $("#"+this.id).datepicker('option', {minDate: new Date(timestamp_from_open*1000)});
            }
            else if(timestamp_from_open < 0 && timestamp_to_open > 0 && from_of_to == 'from'){
                var closest_min = getNextMinVal(geselecteerde_tot_datums, timestamp_to_open);
                $("#"+this.id).datepicker('option', {minDate: new Date(closest_min*1000)});
                $("#"+this.id).datepicker('option', {maxDate: new Date(timestamp_to_open*1000)});
            }
        },
        beforeShowDay: unavailable,
        onSelect: function(selectedDate) {
                var option = this.id.indexOf("from_") != -1 ? "minDate" : "maxDate"; 
                dates[x].not(this).datepicker("option", option, selectedDate); 
        },
        onClose: function (geselecteerdedatums) {
            var from_of_to = this.id.indexOf("from_") != -1 ? "from" : "to"; 
            var date_from = $("#from_"+x).val();
            var date_to = $("#to_"+x).val();
            var timestamp_from = Date.UTC(date_from.substring(6,10),date_from.substring(3,5)-1,date_from.substring(0,2))/1000;
            var timestamp_to = Date.UTC(date_to.substring(6,10),date_to.substring(3,5)-1,date_to.substring(0,2))/1000;
            var aantal_dagen = (timestamp_to - timestamp_from)/86400;
            if (timestamp_from > 0 && timestamp_to > 0){
                    geselecteerde_vanaf_datums.push(timestamp_from);
                    geselecteerde_vanaf_datums.sort();
                    geselecteerde_tot_datums.push(timestamp_to);
                    geselecteerde_tot_datums.sort();
                    geselecteerde_tot_datums.reverse();
                while (timestamp_from <= timestamp_to){
                    datums_niet_beschikbaar.push(timestamp_from);
                    timestamp_from = timestamp_from + 86400;
                }
                periode_half_gevuld = 0;
                $("#half_gevulde_datepicker").val(0);
                $("#datums_bezet").val(datums_niet_beschikbaar);
                $("#datums_vanaf").val(geselecteerde_vanaf_datums);
                $("#datums_tot").val(geselecteerde_tot_datums);
            }
            else if (this.value != ''){
                periode_half_gevuld = x;
                $("#half_gevulde_datepicker").val(x);
            }
        }
    }); 
}); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:09:36+00:00Added an answer on June 16, 2026 at 1:09 am

    I think you have to initialize the datepicker again after AJAX reload.

    jQuery('.datepicker').datepicker({...});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a very complex Oracle package here (over 4,100 lines of code) that's
I have a very complex task - create a software that imports XMl files
I have a very complex graph, and there is no way that I can
Here is the problem: I have a very complex plugin that does lots of
I have a very complex Linq to SQL query that returns a result set
Imagine I have two very complex but identical objects in c#, and I want
I have a very complex UIViewController that loads extremely slow sometimes, it can take
I have a very complex process that involves downloading a number of files from
I've worked on projects that have very complex XML configuration, and one problem that's
I have a very complex query at a beginner level which I am not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.