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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:37:52+00:00 2026-06-09T16:37:52+00:00

my javascript has code, for one of the pages on my website: $(‘#nmdt1’).datetimepicker({ dateFormat:

  • 0

my javascript has code, for one of the pages on my website:

$('#nmdt1').datetimepicker({
        dateFormat: $.datepicker.ATOM,
        minDate: nmsdt,
                  ...
                  ...

this runs fine, when the page on which id=”nmdt1″ is loaded.
And I load the related datetimepicker js library (module) only on when i load that page.
so far so good.

but when i load any other pages on my websit i get this error: from the line number where dateformat is defined.

EDIT: here is the correct error for firebug log:

TypeError: $.datepicker is undefined
http://myswbsite/jscript/myjsscript.js
Line 569

line 569 is:

dateFormat: $.datepicker.ATOM,

and yes, this error only comes on page where I am not loading the related js code (jquery-ui-timepicker-addon.js). The reason I am not loading this js on every page is, i need it on only one page.

MORE DETAILS:

in HTML header following lib loads (in seq)

<head>
    <script src="/jscript/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="/jscript/myjsscript.js" type="text/javascript"></script>
...
...
    <script type="text/javascript">
    jQuery(document).ready(function(){
        var mid = "[% mid %]";
        alert('mid='+mid);
        $(".bvmainmenu #"+mid).css({"background":"url(/images/current-bg.gif) top left repeat-x", "color":"#ffffff"});
    });
    </script>
</head>

this last javascript code you see above (bottom of header) does not run each time when the jquery-ui-timepicker-addon.js lib is not loaded (and you see that err in firebug – i can live with error, but why this last code is not running, i am not sure). I am not able to understand why this routine wont run just because i did not load one ‘add-on’ library

the page which runs everything correctly loads following js scripts in BODY

<script src="/jscript/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<script src="/jscript/jquery-ui-timepicker-addon.js" type="text/javascript"></script>

on this page the last javascript code you see in header also loads and displays the alert!

I am having tough time to figure this.

  • 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-09T16:37:58+00:00Added an answer on June 9, 2026 at 4:37 pm

    You seem to be saying that this code:

    $('#nmdt1').datetimepicker({
        dateFormat: $.datepicker.ATOM,
        minDate: nmsdt,
        ...
    

    …is within your common myjsscript.js script that is loaded on every page. If so, that means it runs on every page and thus you get an error on pages that don’t also include the extra plugin scripts.

    The code I’ve quoted above does not mean “If an element with that id exists call the datetimepicker() method”, it means “Create a jQuery object that may or may not have any elements in it and then call the datetimepicker() method, passing an object with a property set to $.datepicker.ATOM.” That is, even if there is no nmdtd1 element on the page it will still call datetimepicker and still reference $.datepicker.ATOM.

    There are at least three ways you can fix this:

    1. Move that code out of the common myjsscript.js and just put it on the one page that needs it.

    2. Go ahead and include the plugin JS files on all the pages on your site – they’ll be be cached by the browser, so it’s not really a performance hit assuming your users visit several of your pages anyway.

    3. Move that code within a conditional so the .datetimerpicker() part is not executed unless needed.

    For option 3:

    var $nmdt1 = $('#nmdt1');
    if ($nmdt1.length > 0) {
        $nmdt1.datetimepicker({
           dateFormat: $.datepicker.ATOM,
           minDate: nmsdt,
           ...
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple tooltip which has long JavaScript code in the divs. I
In eclipse IDE, how can I see the javascript source code GWT has generated
This has me stumped. The follow code returns ,,,,,,: <script type=text/javascript> $(function() { $('#listB').sortable({
Visual studio seems intent that my javascript code is bad, mostly because it has
I'm getting a javascript error. It has to do with this section of code:
I have a one page site that has PHP code in it. Once the
I have an ASP.NET website (c# as code behind) in which one of my
Javascript has a poorly constructed but convenient arguments variable inside every function, such that
The following JavaScript has some unwanted behaviour: <html> <script> function AddEventListener(el, listener) { el.addEventListener
I was baffled today when someone mentioned on a group that Javascript has evolved

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.