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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:04:10+00:00 2026-06-08T03:04:10+00:00

I have some global variables in my script: var yardsToFirst = 10; var yardsToTD

  • 0

I have some global variables in my script:

var yardsToFirst = 10;
var yardsToTD = 80;
var exactDown = 1;

In my ViewModel I take in and modify the variables. According to Google Chrome’s javascript console the variables are being modified. I try to have them observed so they can update the UI like this:

self.down = ko.observable(exactDown);
self.toGo = ko.observable(yardsToFirst);
self.toGoal = ko.observable(yardsToTD);

It all works fine right when I load the page. The problem comes when I start modifying the data. the UI never changes. I have checked and the javascript console says the global variables hold the correct numbers but still the UI is not updated. Am I doing something that is impossible or have I go about it the wrong way?

  • 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-08T03:04:11+00:00Added an answer on June 8, 2026 at 3:04 am

    You are doing it wrong. When you create knockout observable properties, they will just initialize with the value you gave them, i.e. ko.observable(exactDown). After that, there’s no way for knockout to know when the variable you used for initialization changed. It’s just like you tried to call ko.observable(1).

    Initializing knockout observable property with some global variable doesn’t mean that knockout will start to watch that variable for changes.

    Instead of modifying global variables like you do:

    exactDown = newValue;
    

    …and expecting that knockout will pick up the new value, you need to modify knockout properties directly, like this:

    viewModel.down(newValue);
    

    To modify knockout properties, you need to call them as functions (since they are basically JavaScript functions).

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

Sidebar

Related Questions

I have some global variables in a Python script. Some functions in that script
For some reason I have to access Jenkins global environment variables like BUILD ID,
I have a pretty big Javascript script with loads of global variables & functions
I have a php file that has some local and global variables (e.g. $foo)
I have some jQuery global variables that I want to just put into my
We have an HTML page with some global JavaScript variables. We have some utility
I have a global pointer variable char* pointer = new char[500]; /* some operations...
I have some settings in my app.config which I intend to be 'global' -
I have code in global.asax that sets some things in cache with CacheItemRemovedCallback. When
Some code that I don't have control over is overriding the global JSON object

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.