0
votes

How can I use durandal compose functionality to implement knockout template binding for a sortable, dragging, dropping array?

I am using @RP Niemeyer knockout-sortable plugin witch is using templates.

So far I have made it work by storing the templates in the index file, but I am looking to implement it in the view.

<div class="well droppingZone" data-bind="sortable: { template: 'fieldTmpl', data: fields, options: { update: onUpdate } }"></div>
1

1 Answers

0
votes

I think what you mean to do is to load the template file dynamically, if thats the case, have a look at Ko External template developed by @RP as well which will seamlessly integrate with ko template. However I had some issues when i used ko external with durandal js (guess problem was with infuser), so I changed ExternalTemplateSource.js #getTemplate to use durandal's viewLocator

 getTemplate: function () {
            var self = this;
            //system.log('Loading template:' + self.templateId);
            viewLocater.locateView(self.templateId).then(function (element) {
                self.data("precompiled", null);
                var t = $(element).html();
                setTimeout(function () {
                        self.template(t);

                }, 500);
                self.loaded = true;
            });