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

  • Home
  • SEARCH
  • 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 6344069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:33:59+00:00 2026-05-24T20:33:59+00:00

I want to create a jQuery template(s) that will be used project wide. I

  • 0

I want to create a jQuery template(s) that will be used project wide. I would prefer to put the templates in a separate file or files and compile them on project start up using the template function.

I don’t want to have the templates in the markup, in script tags. Is this possible and how would I do it?

  • 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-24T20:34:00+00:00Added an answer on May 24, 2026 at 8:34 pm

    As RoccoC5 suggested it, you can define a small plugin which will fetch your remote template and then append its content into a script tag to the head:

    (function ($) {
        $.loadTmpl = function (url, name) {
            return $.get(url).success(function (content){
                $("head").append($('<script/>', {
                    id: name,
                    type: 'text/template'
                }).html(content));
            });
        };
    }(jQuery));
    

    and use it with:

    $.loadTmpl('hi.html', 'hi').done(function () {
        $('#hi').tmpl({name: 'Tom'}).appendTo('body');
    });
    

    or:

    $.when(
        $.loadTmpl('foo.html', 'foo'),
        $.loadTmpl('bar.html', 'bar'),
        ...
    ).done(function () {
        // All your templates are now loaded
    });
    

    Hope this help.

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

Sidebar

Related Questions

I want to create a button that has a jQuery click on the fly.
I want to create a jquery script that works like the iphones slide to
I have this HTML page, and I want to create a jQuery method that
I want to create multilevel accordion Navigation using jQuery , I tried using this
I have been tinkering with javasript (jquery) all day. I want to create a
How to create imaged scrollbars, for example: http://www.openstudio.fr/jquery/index.htm Basically, I want to create my
I want to create a jQuery dialog on-the-fly. I'm using this: var newDiv =
I want to create a pagination script using jquery UI's slider widget. So far
I want to create and append an item in jquery, while saving a reference
I want to create a function to simplify configuration of jQuery UI AutoComplete. Here

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.