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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:05:58+00:00 2026-05-27T12:05:58+00:00

Im trying to template some components often used in my project. To omit the

  • 0

Im trying to template some components often used in my project. To omit the introduced redundancy in html content. However i didnt figure it out if it is even possible to do so.

I have a template like:

<script type="text/x-jquery-tmpl" id="somefieldtemplate" >  
<input  name=" Prefix" type="text" data-bind="value: ${ $item.fieldName}SomeField" /> 
   ..... mor contents ... 
</script>

The parameter bound to the input component shall be adjustable as someone may see via template options so i have an entry like

<div data-bind="template: { name: 'somefieldtemplate', 
         templateOptions: 
             { fieldName:'somefield', displayName:'somefieldlabel' } }">

The error message in my console log is:

SyntaxError: Unexpected token {

I narrowed the problem down to the fact that if i remove $item.fieldName with its value it works.

Has anybody an enlightening solution to this problem maybe ?

Edit:

As information im currently using knockout.js in version: knockout-latest

  • 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-27T12:05:59+00:00Added an answer on May 27, 2026 at 12:05 pm

    Sadly i need to answer it myself. But i managed to get it working. Thanks to the tip of RP Niemeyer.

    For everyone interested in this:

    Observables are generated dynamically in the model someModel with a register component method. This observables have always names like <field>SomeField

    Template:

    <script type="text/x-jquery-tmpl" id="somefieldtemplate" >  
    <input  name="${$item.fieldName}Prefix" type="text" data-bind="value: someModel[$item.fieldName + 'SomeField']" /> 
       ..... more contents ... 
    </script>
    

    Template-Binding:

    <div data-bind="template: { name: 'somefieldtemplate', 
             templateOptions: 
                 { fieldName:'somefield', displayName:'somefieldlabel' } }">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use C++ Template 'mixins' to create some new VCL components with
I'm trying to use C++ Template 'mixins' to create some new VCL components with
I'm doing some template work on a personal project and I'm trying very hard
I'm trying to implement some custom template tags to to a little more with
I am trying to build a responsive email template but have run into some
i have a simple template that i populate with some data then im trying
Effectively I'm trying to send some template emails so that I can test a
I'm trying to map some structs to some other instances, like this: template <typename
I'm trying to create some kind of callback for a class template. The code
I am trying to get my head around applying template programming (and at some

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.