Johnny Cash
Johnny Cash

Reputation: 21

Knokcout JS: Uncaught ReferenceError: action is not defined

I am currently using knokcout js to render a view.

HTML:

<div data-bind="template: {data: {ui: uistate, action: actionHandler }, afterRender: doStuff}">
   <custom-comp params="onclick: action.print, shouldShow: ui.showPrint">
   </custom-comp>
</div>

custom-comp is my custom component to render the existing data and perform other actions.

Script:

this.doStuff= function(elements) {
    console.info(elements); 
}

However, even though the custom component gets the data, and everything works as it is supposed to, it still throws the error:

Uncaught ReferenceError: action is not defined
    at onClick (eval at createBindingsStringEvaluator (knockout.debug.js:2936), <anonymous>:3:60)
    at Function.evaluateImmediate_CallReadThenEndDependencyDetection (knockout.debug.js:2142)
    at Function.evaluateImmediate_CallReadWithDependencyDetection (knockout.debug.js:2114)
    at Function.evaluateImmediate (knockout.debug.js:2078)
    at Object.ko.computed.ko.dependentObservable (knockout.debug.js:1939)
    at knockout.debug.js:3821

Upvotes: 0

Views: 837

Answers (0)

Related Questions