Passing parameter using onclick or a click binding with KnockoutJS

前端 未结 5 2080
遥遥无期
遥遥无期 2020-12-25 09:54

I have this function:

function make(place)
{
  place.innerHTML = \"somthing\"
}

I used to do this with plain JavaScript and html:



        
5条回答
  •  無奈伤痛
    2020-12-25 10:20

    I know this is an old question, but here is my contribution. Instead of all these tricks, you can just simply wrap a function inside another function. Like I have done here:

    Click me once
    Click me twice
    var VM = function(){ this.f = function(param){ console.log(param); } } ko.applyBindings(new VM());

    And here is the fiddle

提交回复
热议问题