jbonfardeci / ShockoutForms

SharePoint + Knockout MVVM forms - an InfoPath killer
32 stars 8 forks source link

PostRender function #11

Closed leolorenzoluis closed 8 years ago

leolorenzoluis commented 8 years ago

PostRender function fires too early. I was expecting PostRender to fire after KnockOut template is done?

jbonfardeci commented 8 years ago

Hi there. It sounds like you may have an issue with an asynchronous method. Postrender is called after all elements are added to the DOM but you may have another async method where the data hasn't loaded when expected. In every case where I'm loading async data, say from another list, I store the results in a Knockout observable array on the callback. This guarantees the data will be available on the Knockout view model when it does load.

On Mon, Mar 28, 2016 at 4:32 PM, leolorenzoluis notifications@github.com wrote:

PostRender function fires too early. I was expecting PostRender to fire after KnockOut template is done?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/jbonfardeci/ShockoutForms/issues/11

leolorenzoluis commented 8 years ago

As far as I know I am not calling any asynchronous calls right now to load the data. I get the observable part to listen for changes. My scenario is like this:

I am using check box multi group that requires multiple selection, and I need to apply some changes to the rendered template. I tried subscribing to the FieldName. However, it doesn't fire since there are no changes to it. Could you show me how to handle when the check boxes are rendered?

leolorenzoluis commented 8 years ago

I'm using Material Design for Bootstrap, and I have to call $.material.init() after the check boxes has rendered the template with the model. Do you know if it's possible or do I have to tweak SO?