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

The Archive Base Latest Questions

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

I let us say that I have the following HTML: <input data-bind=value: numberOne, valueUpdate:

  • 0

I let us say that I have the following HTML:

<input data-bind="value: numberOne, valueUpdate: 'afterkeydown'" />
<p/>
<input data-bind="value: numberTwo, valueUpdate: 'afterkeydown'" /><p/>
<span data-bind="text: comp"></span>
<ul data-bind="foreach: stuff">
    <li><span data-bind="text: name"></span></li>
</ul>

and the following ViewModel in ko.js.

function myVm() {
   var self = this;
   var counter = 0;
   var myArray = new Array(5);
    for(i = 0; i < myArray.length; i++){
        myArray[i] = { name: "Blah "+( i + 1 ) };
    }
   self.stuff = ko.observableArray(myArray);
   self.numberOne = ko.observable(0);
   self.numberTwo = ko.observable(5);
   self.comp = ko.computed(function(){ 
    if(counter > 0){ 
        if(self.stuff().length > ( parseInt(self.numberOne(), 10) + parseInt(self.numberTwo(), 10) )){

            for(i = ( parseInt(self.numberOne(), 10) + parseInt(self.numberTwo(), 10) ); i < self.stuff().length; i++){
                self.stuff.pop();
            }
        }else{

                for(i = self.stuff().length; i < ( parseInt(self.numberOne(), 10) + parseInt(self.numberTwo(), 10) ); i++){
                self.stuff.push({ name: "Blah "+( i + 1 ) });
            }
        }

            }
            counter++;
            return parseInt(self.numberOne(), 10) + parseInt(self.numberTwo(), 10); 
           });
}
var vm = new myVm();
ko.applyBindings(vm);

How would I add the jQuery .fadeIn() function​ to the dynamically added list items so that they fade in as the numbers are changed? Here of the JSFiddle link to the above code: http://jsfiddle.net/HdR8L/2/

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

    One option is to add a simple fadeText binding that you can use instead of the text binding. It would look something like:

    ko.bindingHandlers.fadeText = {
        update: function(element, valueAccessor) {
            $(element).hide();
            ko.bindingHandlers.text.update(element, valueAccessor);
            $(element).fadeIn(1000);
        }        
    };
    

    Then, you would use it in place of your existing text binding like: http://jsfiddle.net/rniemeyer/HdR8L/3/

    The other options is to use the afterAdd callback as described here: http://knockoutjs.com/documentation/foreach-binding.html#note_5_postprocessing_or_animating_the_generated_dom_elements

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

Sidebar

Related Questions

Let's say we have the following html: <ul id=portfolio-list class=clearfix span-24> <li class=2012#foo bar
Let's say I have a web page ( /index.html ) that contains the following
Let's say that I have the following HTML for a text box on an
Let's say that I have the following code that's run in one thread of
Let's say that I have the following: int a = 2; Number b =
Let's say that I have 4 models which are related in the following ways:
Let's say I have the following: Vegetable=Potato ( Kind of vegetable that i have
Let's say I have the following HTML: <div> text1 <div> t1 </div> text2 <div>
Let's say I have the following HTML code <div id="outer"> <div id="inner">Hello World</div> </div>
Let's say that I have following situation. I have many customers and many consultans,

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.