1

I am trying to use the jQuery ColumnListView library (found http://code.google.com/p/jcvl/) with KnockoutJS.

I'm having an issue trying to fire a function on my ViewModel when the onItemChecked event is fired in the jCOlumnListView:

Here's an example:

var items = jQuery.fn.jColumnListView({
    id: 'heirarchyclv',
    width: 400,
    columnWidth: 150,
    columnHeight: 200,
    columnMargin: 8,
    paramName: 'columnview',
    columnNum: 4,
    appendToId: 'heirarchy',
    elementId: 'heirarchyTest',
    removeAfter: false,
    columnMinWidth: 120,
    columnMaxWidth: 200,
    childIndicator: true,
    leafMode: true,
    checkAndClick: true,
    useSplitters: false,
    onItemChecked: function (item) {
        // fire the showChildren method on the ViewModel
    }
});

This is setup after the data is loaded for the ul that it is bound to in the html. The listing in the first list view works fine, but I want to be able to click on one of the items in the view and have the method showChildren on my ViewModel get fired, just as if I had bound a button in the list to the showChildren method.

I was thinking I could do something like this perhaps: onItemChecked: function (item) { console.log(item); ko.contextFor(item.elems.elem[0]).showChildren(); }

but that results in a js error that ko.contextFor(item.elems.elem[0]) is not defined.

Any help would be appreciated. Let me know if I can make this question better.

4

0 回答 0