0
votes

I have managed to get code the knockoutJS jqauto auto-complete working as per the fiddle:

http://jsfiddle.net/rniemeyer/PPsRC/

But I require the autocomplete to run inside a template. So i have multiple auto-complete textboxes for each template line/repetition. Once i put the

<input data-bind="jqAuto: { autoFocus: true }, jqAutoSource: items.TaskTypesFlat, jqAutoValue: items.Audit.Task.PerformedByUserId, jqAutoSourceLabel: 'BreadCrumbString', jqAutoSourceInputValue: 'BreadCrumbString', jqAutoSourceValue: 'Id'" />

inside a template (the built-in templates and not jquery tmpl), it errors:

Message: ReferenceError: 'items' is undefined;

I was wondering how do I reference my viewmodel's observable collection correctly from within a template?

I hope someone can help.

Kind Regards Phil

1

1 Answers

1
votes

If your choices live at the root level and you are rendering a template for each item in an array, then you can use the special variable $root.

So, you can use something like: $root.items