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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:28:03+00:00 2026-06-03T03:28:03+00:00

Since Knockout’s individual templates are kept in script tags, I thought that I could

  • 0

Since Knockout’s individual templates are kept in script tags, I thought that I could set the src attribute of the tag and load the HTML from a separate file. Doing so naïvely simply didn’t work, so either

  1. There’s some trick to getting the binding of templates to work with src tag that I need to use
  2. There’s a different way to load templates from different files

(The other two possibilities — 3, all the programmers on this project are expected to modify the same gigantic file, which will be loaded by the browser on start-up, and 4, don’t use Knockoutjs for anything larger than a toy project — I consider equivalent.)

  • 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-03T03:28:05+00:00Added an answer on June 3, 2026 at 3:28 am

    A browser won’t respond to src on anything that has a type other than one of the various ‘javascript’ types and with those it will try to execute the result as a script.

    Several options though:

    • use a template engine that can pull templates remotely (the best one is here: https://github.com/ifandelse/Knockout.js-External-Template-Engine).
    • Loop on your script tags that contain templates and load them up. Something like this would pull the contents using the src as the location. You would need to be careful of when you call applyBindings, if your templates aren’t ready.

      $("script[type='text/html']").each(function(index, el) { $.get($(el).attr("src"),
          function(response) {
              $(el).text(response); });
      }); 
      
    • Here are some other options that I looked at for doing this a while back: http://www.knockmeout.net/2011/03/using-external-jquery-template-files.html

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

Sidebar

Related Questions

Since REST is stateless, each request that comes in has no knowledge of the
I'm working with a new application at work that we're building out using Knockout.js
Since injected script can't do cross domain xmlhttp requests I tried, as it is
Since jQuery Mobile's method changePage will load only the element with the data-role=page attribute
I have the following working code that uses Knockout to determine what color to
Since a few years, common sense seems to dictate that it's better to program
Since named parameters are those parameters that are identified by their explicit name, instead
Since the GAS documentation actually sucks, I thought I might try to at least
Since url JavaScript should be injected into the webview, could someone let me know
In trying to spice up a knockout.js UI with effects, I've found that I

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.