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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:15:10+00:00 2026-06-17T09:15:10+00:00

I think my issue comes from using Knockout.js with jquery.tmpl.1.0.0pre.js where existing DOM script

  • 0

I think my issue comes from using Knockout.js with “jquery.tmpl.1.0.0pre.js” where existing DOM script templates become pre-compiled? I’m trying to figure out how to pump external html templates in to a page (which I’ve done) but also get Knockout.js to use them (which currently fails with errors.) BTW, I’m applying Knockout bindings after all ajax calls complete.

Here’s the steps I went through:

My first step: I moved the in-line html template to Javascript, which worked well including with Knockout.js:

$('#templates').append(
    '<script type="text/x-jquery-tmpl" id="DDLTmpl">' +
        '<select data-bind="options:options(),value:$item.data.value,' +
        'optionsCaption:caption(),optionsText:\'text\',optionsValue:\'value\'">'+
        '</select>' +
    '</script>');

Second step: I loaded the same HTML from a separate file from the same domain and inserted it in the DOM:

$.ajax({
    url: '/somewhere/Tmpl.htm',
    data: {},
    success: function(data) {
        $('#templates').append(
            $('<script type="text/x-jquery-tmpl" id="Tmpl" />').html(data)
         );
    },
    dataType: 'html'
});

This succeeded, but caused Knockout to get an “illegal character” error ');if(typeof(\'$\' + fns.fM)!=='undefined' && (\'$\'. Looking at the two templates in the DOM, one is encoded with this:

{{ko_code ((function() { return ko.templateRewriting.applyMemoizedBindings...

and the second appears as if the html were cut and pasted in the div as expected.

Do I need to pre-compile a template? How would I encode a template to work with Knockout.js?

My next step is to remove the jquery.tmpl.1.0.0pre.js dependency and use the native Knockout.js template engine (or doT.) I’m currently using Knockout 2.1.0.js.

  • 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-17T09:15:11+00:00Added an answer on June 17, 2026 at 9:15 am

    Use the built in way of defining template sources instead, much easier.

    Ryan has a good article on it, http://www.knockmeout.net/2011/10/ko-13-preview-part-3-template-sources.html

    Or you can checkout how I did it for my KO Combobox binding

    https://github.com/AndersMalmgren/Knockout.Combobox

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

Sidebar

Related Questions

I have a batch script, I think my issue has to do with parentheses
Note: Now that I know where the issue comes from, I modified the question.
I'm using RavenDB to hold several thousand documents. The data comes from a daily
I am using jquery mobile and I have an annoying issue... When an element
I'm having a solr query syntax issue (I think) with solr 1.4. I'm trying
I've run into an animation issue (I think) with my TabBar based app. I
My issue is quite simple I think : I would like to be able
I think I am overthinking this issue a little and I'm hoping someone can
I think this is an escaping issue or something. When I execute the query
I think I am running into a context issue and hoping someone can shed

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.