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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:38:00+00:00 2026-06-18T02:38:00+00:00

How to I access a javascript template that is reused throughout my site, and

  • 0

How to I access a javascript template that is reused throughout my site, and do so within javascript and bind a object to it. I would like access to the template as a string so I can add it in the content property below in a Google Maps Info Window.

I know there’s this function ko.renderTemplate("myTemplate", accessor, {}, element, 'replaceNode'); but how can I get that to return me the string to shoot to the info window?

<script type="text/html" id="info-window-test">

   <span data-bind="text: Name"></span>

</script>

   var html = TODO: Get Template With Data

  /***************** OLD WAY
    var html = '<div class="info-window">';

        html = html + '<div><b>' + location.City + ', ' + location.StateRegion + '</b></div><hr/>';

        length = location.Events.length;

        $.each(location.Events, function (index, item) {
            html = html + '<div><a target="_blank" href="' + item.Link + '">' + item.Name + '</a></div>';
            html = html + '<div><i>' + item.DateFormatted + '</i></div>';

            if (index < length - 1) {
                html = html + '<hr/>';
            }
        });

        html = html + '</div>';
    **************************/

    var infoWindow = new google.maps.InfoWindow({
       content: html
    });
  • 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-18T02:38:01+00:00Added an answer on June 18, 2026 at 2:38 am

    If I have understood your question correctly it should be “Can I use KnockoutJS as a simple template engine?” and the simple answer is No, you cannot.

    But you can use the DOM temporally to achieve what you want.

    Check this jsfiddle http://jsfiddle.net/angelyordanov/zQZT8/.

    <script type="text/html" id="info-window-test">  
      <span data-bind="text: Name"></span>  
    </script>  
    
    var viewModel = { Name: 'John' };
    
    var templatePlaceholder = 
      $('<div style="display: none" data-bind="template: { name: \'info-window-test\' }"></div>')
      .appendTo('body');
    
    ko.applyBindings(viewModel, templatePlaceholder[0]);
    
    var resultHtml = templatePlaceholder.html();
    
    ko.cleanNode(templatePlaceholder[0]);
    templatePlaceholder.remove();
    
    alert(resultHtml);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I access(throught JavaScript) an anchor element without it having any attributes except
It's not that I don't have access to javascript, of course. In most of
Possible Duplicate: javascript object, access variable property name? I'm trying to call a method
It looks like JavaScript does not have access to authentication cookies ('ASP.NET_SessionId', '.ASPXFORMSAUTH') in
Is there a Javascript framework that allowed to access to user's phonebook contacts?
In django, I can render a html template from a view action like this:
Is it possible that some javascript or jquery can handle this: I have an
I'm loading an HTML template file, which contains templates that I'm using throughout my
I put some client-side Javascript in my template that allows a user to dynamically
Before I created http://khmerlc.org/khmerkeyweb/ with javascript that allow user input cambodia unicode user can

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.