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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:57:45+00:00 2026-06-12T08:57:45+00:00

I’m using the bootstrap datepicker plugin and I need to overload the headTemplate object

  • 0

I’m using the bootstrap datepicker plugin and I need to overload the headTemplate object at the end of the plugin.

That looks like this:

var DPGlobal = {
        modes: [ ... ],
        isLeapYear: function ( year ) {
             [...]
        },
        [...]

        headTemplate: '<thead>'+
                        '<tr class="datepicker-btn-group">'+
                            '<th class="prev"><div class="dp-btn"><i class="timely-icon-arrow-left"/></div></th>'+
                            '<th colspan="5" class="switch"><div class="dp-btn"></div></th>'+
                            '<th class="next"><div class="dp-btn"><i class="timely-icon-arrow-right"/></div></th>'+
                        '</tr>'+
                    '</thead>',
       contTemplate: '<tbody><tr><td colspan="7" class="grid-picker"></td></tr></tbody>'
};

So, admittedly I’m still learning javascript, so I’m trying to wrap my head around why the following code won’t do what I want.

First of all, I need to check that external JS file is loaded and the function is available, I’m attempting to do that with jQuery’s .load() method with a callback. I am getting some reference errors with the document target and I am admittedly confused about best practice for this – really I just want to say

$( 'lib/bootstrap-datepicker/js/bootstrap-datepicker.js' ).load( function() {
 // overwrite/load function 
}); 

but that is throwing a bunch of target/reference errors, so instead, I’m trying the following because the jQuery docs indicate that I need to pass the script I’m checking as the first parameter in a call to the .load() function rather than the target. This often confuses me – referencing things in jQuery when I want to execute a function that is somehow global and does not refer to anything specific (hence the document reference attempt).

$( document ).load( 'lib/bootstrap-datepicker/js/bootstrap-datepicker.js', function() {
    origDPGlobal.headTemplate = DPGlobal.headTemplate;
            DPGlobal.headTemplate = // 'string of HTML for new template';
});

Last thing (sorry for the barrage everyone), is that I’m not understanding how headTemplate is originally declared via colon:

var DPGlobal = {
    [...],
    headTemplate: '// html string',
    contTemplate: '//html string'
};

Do I need to re-declare these as prototypal objects from an array, like this?

DPGlobal[headTemplate] = '// new html string';
DPGlobal[contTemplate] = '// new html string';

Thanks so much for helping a newb!

  • 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-12T08:57:47+00:00Added an answer on June 12, 2026 at 8:57 am

    Couple things:

    First, load is used to load the contents of the file into the element. You instead are looking for getScript http://docs.jquery.com/Ajax/jQuery.getScript

    Second, the following are the same (just creating objects):

    //one way to build an object
    var DPGlobal = {
        headTemplate: '// html string',
        contTemplate: '//html string'
    };
    
    //another way to build the same object
    var DPGlobal = {};
    DPGlobal.headTemplate = 'html string';
    DPGlobal.contTemplate = 'html string';
    

    You see, that curly braces method just sets properties on the object initially, the same as if you assigned them later.

    Third, your guess about how to override the templates is close. You need to use strings if you reference properties in square brackets:

    //your way
    DPGlobal['headTemplate'] = '// new html string';
    DPGlobal['contTemplate'] = '// new html string';
    
    //same as
    DPGlobal.headTemplate = '// new html string';
    DPGlobal.contTemplate = '// new html string';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.