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
Message from discussion accessing $data in afterRender function call
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
 
hughb...@gmail.com  
View profile  
 More options May 21 2012, 1:27 am
From: hughb...@gmail.com
Date: Sun, 20 May 2012 22:27:29 -0700 (PDT)
Local: Mon, May 21 2012 1:27 am
Subject: Re: accessing $data in afterRender function call

Good evening,
I'm having a problem in version 2.1.0 of Knockout Js with the ko foreach
binding inside of containerless control flow syntax, when specifying
afterRender, same setup as the OP.

Problem is, the afterRender is called for each item in the list.
I was hoping to have it called one time after the whole list has been
processed.
I need to tell jQuery Mobile to re-render it's styles on the containing UL
list which has a header item which is not KO bound.
I run into problems if I tell jQuery Mobile to re-render during the
afterRender call currently specified in the ko foreach comment as the OP
has it.
That is because if the list contains multiple items, I tell jQuery to style
it in item 1's callback,
then Knockout tries to add item 2 and jQuery has modified the DOM.
 Knockout gets lost because the DOM is not as expected.

Solution would be for the afterRender to only fire after the whole foreach
is finished.
If I wanted it to callback during every iteration I could bind to the
afterRender on one of my li elements inside the foreach.

Thanks!
H

On Thursday, December 1, 2011 6:21:47 AM UTC-7, Michael Best wrote:

> I think this will work:

> <!-- ko foreach: {data: viewModel.Files(), afterRender:
> function(elems, data) { do something with data.id(); } }  -->

> -- Michael Best


 
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.