Organiccat
Organiccat

Reputation: 5651

Adding a bindinghandler with jqueryui sortable in knockout

I'm adding a sortable element on a table, it's a new requirement right at the end of the project so I don't feel I have the time to learn and add the knockout-sortable plugin. I tried adding a binding handler with a simple call to the element using jqueryui to make it sortable but ran into an error:

Object [object Object] has no method 'sortable'

The binding handler is really simple:

ko.bindingHandlers.sortItems = {
    init: function () {
        $('#itemGroup').sortable();
    }
};

and the table is a table with a data-bind: foreach, looping through an array of items:

<tbody id="itemGroup" data-bind="foreach: itemDetails, sortItems: {}">

Any idea where I could be going wrong here?

Upvotes: 0

Views: 128

Answers (1)

Aliaksei Shytkin
Aliaksei Shytkin

Reputation: 425

It seems sortable plugin is not loaded when you call it. Check order of tags.

Upvotes: 2

Related Questions