Template.renderItem method RRS feed

  • Question

  • Hello guys.

    After reading the docs, I'm still not clear on when I should this method instead of render. Any ideas?


    Luis Abreu

    Friday, March 30, 2012 9:33 AM

All replies

  • I took a look at the docs and binding.js.

    This from the docs pretty much sums it up:

    Renders an instance of this template bound to the data contained in item. If the recycled parameter is present, and enableRecycling is true, then the template attempts to reuse the DOM elements from the recycled parameter.

    What is really confusing is that the last parameter is NOT a boolean as it is documented but should be a previously generated DOM Element that matches the template.  I could not find any sample that uses this but how I imagine it may work is if you are changing the data you were displaying in the template (and it was not occuring multiple times) you could pass the DOM Element you created the first time you rendered the template.


    Type: DOM Element

    A previously-generated template instance.

    Jeff Sanders (MSFT)

    Friday, March 30, 2012 8:23 PM
  • Hello again Jeff.

    Oh I see. If the idea is to reuse some previously generated HTML instead of recreating a new one, then it should be slight fast. I'll have to write a test for it, but if it works like I think, then this is what I should be using for my edit form. Since it shows only one record at the time but since it allows me to navigate between records, then refreshing the UI when navigating between should probably be done by renderItem instead of render.

    I'l give it a go and then I'll provide some more info here.

    Luis Abreu

    Sunday, April 1, 2012 2:26 PM
  • Well , it seems like there's more to it than it seems at first look.

    For instance, I can't seem to reuse the HTML element because its msOriginalTemplate property is not set. 

    I've tried generating a template through the render method and reusing that HTML generated on the next renderItem call, but it simply didn't work.

    So, more ideas on how to use this?

    Luis Abreu

    Monday, April 2, 2012 11:31 AM
  • *bump*


    Luis Abreu

    Monday, April 9, 2012 2:17 PM