jQuery.tmpl is not a function

2,496 views
Skip to first unread message

jrit

unread,
Jan 16, 2011, 3:12:05 PM1/16/11
to KnockoutJS
When setting up a template I got an error and was unable to find
documentation about it.

This is the stack from Firebug, with the error message at the top
obviously. When I went through, I confirmed that jQuery.tmpl existed
initially, but in the closure for renderTemplate it was undefined.

jQuery.tmpl is not a function
(?)(template="calendarTemplate", data=[Object { ClientType={...},
Clients={...}, more...}], options=Object {})knockout-1.1.2.js (line
1799)
executeTemplate(targetNodeOrNodeArray=div,
renderMode="replaceChildren", template="calendarTemplate", data=Object
{ ClientType={...}, Clients={...}, more...}, options=Object
{})knockout-1.1.2.js (line 1461)
whenToDispose()knockout-1.1.2.js (line 1496)
evaluate()knockout-1.1.2.js (line 708)
dependentObservable(evaluatorFunctionOrOptions=function(),
evaluatorFunctionTarget=null, options=Object {})knockout-1.1.2.js
(line 744)
renderTemplate(template="calendarTemplate", data=Object
{ ClientType={...}, Clients={...}, more...}, options=Object {},
targetNodeOrNodeArray=div,
renderMode="replaceChildren")knockout-1.1.2.js (line 1503)
update(element=div, valueAccessor=function(),
allBindingsAccessor=parsedBindingsAccessor(), viewModel=Object
{ ClientType={...}, Clients={...}, more...})knockout-1.1.2.js (line
1544)
invokeBindingHandler(handler=function(), element=div,
dataValue=function(), allBindings=parsedBindingsAccessor(),
viewModel=Object { ClientType={...}, Clients={...},
more...})knockout-1.1.2.js (line 1010)
(?)()knockout-1.1.2.js (line 1046)
evaluate()knockout-1.1.2.js (line 708)
dependentObservable(evaluatorFunctionOrOptions=function(),
evaluatorFunctionTarget=null, options=Object {})knockout-1.1.2.js
(line 744)
applyBindingsToNode(node=div, bindings=null, viewModel=Object
{ ClientType={...}, Clients={...}, more...})knockout-1.1.2.js (line
1050)
(?)(element=div)knockout-1.1.2.js (line 1062)
arrayForEach(array=[div.Confirmation, div.ScheduleEntryStep,
div.ShadowBox, 33 more...], action=function())knockout-1.1.2.js (line
27)
applyBindings(viewModel=Object { ClientType={...}, Clients={...},
more...}, rootNode=body#ctl00_BodyTag)knockout-1.1.2.js (line 1061)
(?)()schedule.js (line 348)
noConflict()jquery.js (line 54)
inArray()


So I made this change as a workaround, which is so far working fine.Or
in any case, at least makes jQuery['tmpl'] available in the
renderTemplate function - not sure yet if I might be breaking
something else but I at least wanted to report the issue.

var tmpl = jQuery['tmpl']; //added

this['renderTemplate'] = function (template, data, options) {
.........
return tmpl(templateText, data); //changed
};

I'm using the debug release but was getting the same error in the
production release, I switched to debug so I could try to find a
workaround. The version of tmpl I'm using is the one that is linked on
the KO site and version of jQuery is 1.4.2

mkidder

unread,
Jan 19, 2011, 9:19:45 AM1/19/11
to KnockoutJS
Is JQuery.tmpl loaded before Knockout? It needs to be. Otherwise, I
see no reason why you are getting the error without looking at your
sample template.
Reply all
Reply to author
Forward
0 new messages