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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:03:55+00:00 2026-06-10T21:03:55+00:00

I have a JSFiddle though I seem to be having an issue with it.

  • 0

I have a JSFiddle though I seem to be having an issue with it. Down in viewModel.showDetails I can’t seem to call getter functions to return model values. I don’t have this problem locally.

What I’m really trying to do and resolve, however, is to only render the table rows for the individual drug clicked on in the list at the top of the “result” panel. Right now, it’s rendering out all drugs, when I only want it to list the drug you click on.

I’ve included the data I’m dealing with that’s returned from the server. This is the data object at the top of the JavaScript panel.

I then add a “showModal” property to each record. It’s set to false. In theory, this is my flag to determine rendering of this model object within the table, i.e., we only want to show this individual model object, not all of them.

The visibility of the table is tied to “showDetails” which toggles the showModal property on the individual model object (the drug clicked from the list above). This is where I’m having the getter errors in the fiddle.

Anyone have any ideas how I can restrict my rendering within the table? This is a very reduced case of what I’ve got locally and I’m not sure why I can’t call obj.showModal() as outlined above to retrieve values, but hopefully this gives you an idea of what I’m doing.

  • 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-10T21:04:01+00:00Added an answer on June 10, 2026 at 9:04 pm

    Fixed: http://jsfiddle.net/JpJQE/7/ (NOTE: knockout.mapping.js may not load in this jsFiddle. For some reason my computer refuses to connect to raw.github.com. You can replace the managed resource with a working link)

    You are on the right track but are over-complicating it a little bit. You do not need to add a new property to every single item in your array. You just need to keep track of what item it is that you want to show. Ex:

    var viewModel = ko.mapping.fromJS(data);
    viewModel.visibleDrug = ko.observable();
    viewModel.showDetails = function(drug)
    {
        viewModel.visibleDrug(drug.pdlId);
    }
    
    ko.applyBindings(viewModel);
    

    Also, if you use a visible in the same binding as your foreach, then your visible binding will be scoped at the parent level and not the item level. So, this will either show or hide ALL drugs. To differentiate between items of your array, you will need to place your visible binding within the foreach loop. Ex:

        <tbody data-bind="foreach: preferredDrugs"> 
            <!-- ko if: $root.visibleDrug() == pdlId -->
                ... repeating content ...
            <!-- /ko -->
        </tbody>
    

    ​

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

Sidebar

Related Questions

We have had an applet built for us in JSFiddle. It only works though
I currently have this, it was working in jsFiddle, though its giving me errors,
I have some Google+ like circles, and I can't seem to get the overflow
I'm having troubles removing the styles from my span in Chrome. It can have
I've searched this site and I can't seem to find an answer. I have
I have started looking into Backbone.js and I seem to be having trouble figuring
I can't seem to grasp what I have to do here. I'm trying my
I have: http://jsfiddle.net/Gkz4v/9/ .pagination li a { float: left; width: 6px; height: 6px; line-height:
I have a jsFiddle that I am working with: http://jsfiddle.net/aL7Xe/77/ It all works great,
I have a jsfiddle here : http://jsfiddle.net/hhimanshu/eLhLS/1/ Current: On keypress, it keeps on appending

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.