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 7496059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:27:44+00:00 2026-05-29T18:27:44+00:00

I have an input [date_caisse] with class: datepicker-inline AND id: [date_caisse] I have this

  • 0

I have an input [date_caisse] with class: datepicker-inline AND id: [date_caisse]

I have this function initialized on all my web pages:

function InitEvents () {

$('.datepicker-inline').datepicker({

    showButtonPanel: true,  /*added by oussama*/
    changeMonth: true, /*added by oussama*/
    changeYear: true, /*added by oussama*/
    firstDay: 1,
    dateFormat: 'yy-mm-dd',/*'dd/mm/yy'*/
    onSelect: function (dateText, inst) {
        //alert('select!');
        id = $(this).attr('id');
        parts = id.split('-');
        id2 = parts[parts.length -1];
        $('#datepicker-target-id-' + id2).val(dateText);
    }
});

}

I want to apply onSelect only on the current page, so this is what I did:

$('#date_caisse').datepicker({

    onSelect: function (dateText, inst) {
        alert('select!');
    }
});

When I put alert(‘select!’); on the main js file (which is called in all pages) it works! but it doesn’t when I try to trigger the action through the current file.

Maybe, onSelect shouldn’t be called twice.

So, anyone could help me please?

Thanks and have a good day!

  • 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-05-29T18:27:46+00:00Added an answer on May 29, 2026 at 6:27 pm

    Did you put your second function inside a jquery initialization block?
    I mean, it should looks like

    $(function(){
       $('#date_caisse').datepicker({
          onSelect: function (dateText, inst) {
             alert('select!');
          }
       });
    });
    

    Edited:

    Ok, I got it.
    The first time the datepicker is initialized, the original dom element is marked with a new class addition, called hasDatepicker that prevent subsequent initialization/reconfiguration.
    The way I found to get rid of it is to remove that marker befor doing any modification to the datepicker’s configuration.
    Thus:

    $(function() {
       $('#date_caisse').removeClass('hasDatepicker');
       $('#date_caisse').datepicker({
           onSelect: function(dateText, inst) {
               alert('overridden!');
           }
       });
    });
    

    Give it a try!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my web application, I have users input a date in a simple textbox.
I have a function that attaches the jQuery UI DatePicker (with my options) to
I have a php function to add number of days to input date function
Thanks for looking, all sincerely helpful answers are up-voted. I have some date input
I have an input text containing a default date and I'm using jQuery's Datepicker
I have a textfield that users input the date using a modified jquery datepicker.
I'm currently working with jQuery and using the datepicker. I have two input fields:
I have two input fields fromDate and toDate which are instances of Date class.
I have a jquery autocomplete field working fine followed by a date input field.
Is there anyway to find the date difference in php? I have the input

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.