Search code examples
kolite

KoLite asyncCommand accessing element data


So I'm displaying a observable array in my view, and I want to be able to remove an element from that list using asyncCommand. However, I'm not sure how I should be getting that element. Is there a way of accessing or passing the selected element into the asyncCommand method?

Thanks for the input


Solution

  •         addGroupCmd = ko.asyncCommand({
                execute: function (data, complete) {
                    //access your observable here with the data object 
                    //EX. var demo = data.id();
                },
                canExecute: function (isExecuting) {
                    return !isExecuting && isEditing();
                }
            }),
    

    Ok, so I figured it out with it little bit of google's help. All you have to do is pass in the data parameter and ko.lite will figure out what object your talking about. pretty nice, not really sure how it works, but it does.