Machinarius
Machinarius

Reputation: 3731

KnockoutJS click binding never called

function UserModel() {
    self.forgeTransactions = function() {
        console.log("forgeTransaction()");
    }

    self.navigateToNew() = function {
        console.log("navigateToNew()");
    }
}

ko.applyBindings(new UserModel());

<button class="btn" style="float: right" data-bind:"click: forgeTransactions">Add fake transaction</button>

The problem with this code is that forgeTransaction is never called whilst if i change the click binding to navigateToNew i can clearly see "navigateTwo" on the console.

Why is this happening?

Note: I can attach the entire source if needed.

Upvotes: 0

Views: 76

Answers (2)

MichaelS
MichaelS

Reputation: 7123

You should write data-bind= not data-bind:

Upvotes: 3

Josh Lowry
Josh Lowry

Reputation: 447

Your function is called forgeTransactions but you are attempting to call forgeTransaction in the button data-bind.

Upvotes: 1

Related Questions