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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:46:59+00:00 2026-06-05T00:46:59+00:00

I just started reading, and go through some knokout tutorial, and really like it,

  • 0

I just started reading, and go through some knokout tutorial, and really like it, but Cannot make a simple sample by myself. Here is HTML code

<input id="Button2" type="button" value="+" data-bind="click:increment" />
<input id="Text1" type="text" data-bind="text:foo" />

and js code:

<script type="text/javascript">
    function AppViewModel() {
        this.foo = ko.observable('0');
        this.increment = function () {
            alert(foo);
            foo += 1;
        };
    }
    ko.applyBindings(new AppViewModel());


</script>

basically i want jsut increment a textbox value by clicking a button. I included in header the following js file as well:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
    <script src="Scripts/knockout-2.1.0.debug.js" type="text/javascript">

What else am I missing? Any help would be greatly appreciated

  • 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-05T00:47:01+00:00Added an answer on June 5, 2026 at 12:47 am

    You are using a text binding on an input. Setting the text of an input doesn’t do anything visibly.

    You need to use the value binding instead. Like so.

    <input id="Button2" type="button" value="+" data-bind="click:increment" />
    <input id="Text1" type="text" data-bind="value:foo" />
    

    You also needed to assign the foo element by calling the observable function.

    function AppViewModel() {
        var self = this;
        this.foo = ko.observable(0);
        this.increment = function () {
            self.foo(self.foo() + 1);
        };
    }
    

    http://jsfiddle.net/madcapnmckay/wdVYe/

    Hope this helps.

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

Sidebar

Related Questions

I'm just getting started with ASP.NET MVC, mostly by reading ScottGu's tutorial . To
I've just started reading through Core JavaServer Faces, 3rd Ed. and they say this
I'm just getting started with rails and I'm a little confused reading through different
I have just started reading through The C Programming Language and I am having
I just started reading on Douglas Crockford's Javascript The Good parts where he explains
I just started reading Hacker's Delight and it defines abs(-2 31 ) as -2
I have just started reading Modern C++ Design Generic programming and Design Patterns Applied
I have just started reading about ORMLite since I am interested in using it
Forgive if this question is silly. I just started reading the SugarCRM developer documentation
I just started programming in C# and was reading about dividing your application /

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.