BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
857 stars 130 forks source link

After view.refresh() got TypeError: tmpl.render is not a function #152

Closed koniczynek closed 11 years ago

koniczynek commented 11 years ago

Hello, smee again ;)

Here is a bit of code that worked before updating jsviews to newest version:

view.tmpl = "commentEditTemplate";
view.refresh();

I receive the following error

TypeError: tmpl.render is not a function jquery.views.js Line 510

iboware commented 11 years ago

Try this:

view.tmpl = $.templates.commentEditTemplate;
BorisMoore commented 11 years ago

That is because of a breaking change in commit 27, called out in the commit notes: https://github.com/BorisMoore/jsviews/commit/94eb0426fd7ef709ccb49c82f5d4b9f749e3695e

_12: When setting a template on a view object, it should be a compiled template, not a name or selector string. See 06_accordionswitching-template.html

The sample here shows you how to update your code, to assign a compiled template, not just the name of a named template: https://github.com/BorisMoore/jsviews/blob/master/demos/step-by-step/06_accordion_switching-template.html#L83

Ah, @iboware got in first! Thanks, Yes, that's right!

koniczynek commented 11 years ago

I am very sorry guys. I thought that the last changes broke this so I only read notes 29 to 31. Sorry for this.