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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:00:39+00:00 2026-06-10T14:00:39+00:00

In my page, I have a drop down (select) and then a table, both

  • 0

In my page, I have a drop down (select) and then a table, both of which are bound to the view model. When I change the drop down the table refreshes with the data associated with that item in the select.

I want to do some UI processing on the table after it is populated. I tried subscribing to the drop down selection (which does get fired and my function called) but the table data is updated after the subscribe completes.

What I want to do is update the table background row colors using a simple function like so:

updateRowBgColors = function (tableId) {
    $("#" + tableId + " tr:gt(0):odd").css("background-color", "#f7f7f7");
    $("#" + tableId + " tr:gt(0):even").css("background-color", "#fff");
};

Yes, I know I can set a class for alternating rows in the data-binding in html, but that wouldn’t answer my question about why this wouldn’t work.

  • 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-10T14:00:40+00:00Added an answer on June 10, 2026 at 2:00 pm

    You can use the afterRender binding along with your foreach binding:

    <table>
        <tbody data-bind="foreach: {data: people, afterRender: doYourThing}">
            <tr>
                <td data-bind="text: Name"></td>
                <td data-bind="text: Number"></td>
            </tr>
        </tbody>
    </table>
    

    And in your view model:

    self.doYourThing = function(insertedDomElementArray, dataItem) {
        $('tr:odd').css("background-color", "#f7f7f7");
        $('tr:even').css("background-color", "#fff");
    };
    

    fiddle

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

Sidebar

Related Questions

I have one drop down list in my page, which contains two options. What
I have a drop-down list hardcoded in an MVC View User Control page and
I have a drop down list which is dynamically generated using ajax on page
I have a dynamic drop down box which calls another PHP page. I've got
I have a drop down which has a method which binds data to it:
i have a drop down list which is populated dynamically from database table i.e
I have a parent page which has a drop down list in it. using
I have a View Feedback page with two drop down lists to filter the
On my page I have a drop-down select box, with a default value of
I have a drop down that I select a file type from, I then

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.