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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:49:34+00:00 2026-06-09T13:49:34+00:00

I have a big problem with using Knockout JS. In my view model I

  • 0

I have a big problem with using Knockout JS. In my view model I have a field, called Method, that is actually an other view model.

This view model can be one of three different things (it is mapped to a polymorphic object in the domain model). To solve this I use templates that checks which type of Method that is selected withing the domain model and then shows the template that binds data for that type.

The function that checks the type of method looks like:

this.getTemplate = function (data) {
        var method = data.original.get_Method();
        if (method instanceof MyProj.MethodA)
            return "methodA";
        else if (method instanceof MyProj.MethodB)
            return "methodB";
        else if (method instanceof MyProj.MethodC)
            return "methodC";
    }

The markup where I bind the template looks like:

<div data-bind="template: {name: getTemplate($data), data: $data.Method}"></div>

This actually works very nice and when I change the type of method via an dropdown in the UI the domain model updates and the right template is shown. However here comes my problem. Each template contains a number of different fields that are specific for each method type. Whenever I change one of the values in the view model displayed by one of the templates the UI flashes and I think that happens because the template get selected again. This is quite irritating and looks extremly bad.

Any ideas on how to solve this problem? Any help would be greatly appreciated!

Thanks in advance

/Björn

  • 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-09T13:49:35+00:00Added an answer on June 9, 2026 at 1:49 pm

    Did you use any observable inside the getTemplate function. Updating the value of that observable makes the template rerender and you get your flash effect.

    Checkout this link Part : “Note 5: Dynamically choosing which template is used“.

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

Sidebar

Related Questions

I have this big problem that i dont know how to fix. I have
I'm using editor from Kendo UI, so I have big problem. I don't know
I am using gettext in my PHP code, but I have a big problem.
I am in a big problem ..i have compiled my c files using linux
I have a big problem that a recursive treeview doesn't update any childs if
I have a big problem that is I have implemented a scheduler in my
I have a big problem. I want to extract text from html table that
I have a big problem using highcharts, because I have been trying for hours
i have a big problem here..i am using Microsoft charting controls in my asp.net
I have a very big problem and can't seem to find anybody else on

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.