Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
I need to know when KO is done rendering DOM elements
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
lecynkar  
View profile  
 More options Jan 23 2012, 5:41 pm
From: lecynkar <lecyn...@gmail.com>
Date: Mon, 23 Jan 2012 14:41:28 -0800 (PST)
Local: Mon, Jan 23 2012 5:41 pm
Subject: I need to know when KO is done rendering DOM elements
I'm using the  built in templating with KO, and I need to know when KO
is done rendering the table data DOM elements so that I can apply some
formating on it.  See the table code below:

<table id="StatusRecipientsTable" class="DataGridTable">
        <thead>
                <tr>
                        <th class="Sortable" data-bind="click:
statusTableSortByNameClick">Member Name</th>
                        <th class="Sortable" data-bind="click:
statusTableSortByEmailAddressClick">Email Address</th>
                        <th class="Sortable">Date Sent</th>
                        <th class="Sortable">Date Read</th>
                        <th class="Sortable" data-bind="click:
statusTableSortByStatusClick">Status</th>
                        <th>Error Message</th>
                        <th />
                </tr>
        </thead>
        <tbody data-bind='foreach: { data:
recipientsForStatusTableFilteredByStatus, afterRender:
stripeStatusRecipientsTableOnChange }'>
                <tr>
                        <td data-bind="text: Name"></td>
                        <td data-bind="text: EmailAddress"></td>
                        <td data-bind="text: SendDate"></td>
                        <td data-bind="text: ReadDate"></td>
                        <td data-bind="text: Status"></td>
                        <td data-bind="text: ErrorMessage"></td>
                        <td class="Center"><a href='#' class="RemoveLink" data-bind='click:
$root.deleteRecipient'>Remove</a></td>
                </tr>
        </tbody>
</table>

I'm using the afterRender hook, but when I filter the underlying data
it's length property is not consistent with the table rows being
rendered. I need to know when it's done rendering

Here is the afterRender function:

var stripTableRowCounter = 0;

viewModel.stripeStatusRecipientsTableOnChange = function (element) {
        stripTableRowCounter++;
        if (vm.recipientsForStatusTableFilteredByStatus().length ===
stripTableRowCounter) { // This is equal when the last DOM element is
rendered
                $('#StatusRecipientsTable tbody tr:odd').addClass('Stripe');
                stripTableRowCounter = 0;
        }

};

My Observable Code:

viewModel.recipientsForStatusTableFilteredByStatus =
ko.computed(function () {
        var filter = this.recipientsEmailStatusFilter();
        if (filter === "All") {
                return this.recipientsForStatusTable();
        } else {
                return ko.utils.arrayFilter(this.recipientsForStatusTable(),
function (item) {
                        if (item.Status() === filter) {
                                return true;
                        }
                });
        }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »