Home > DeveloperSection > Forums > javascript function on data-bind
Takeshi Okada
Takeshi Okada

Total Post:89

Posted on    August-22-2014 1:42 AM

 ASP.Net ASP.Net 

 1 Reply(s)
 875  View(s)
Rate this:

Is there a way i can call JavaScript function on data-bind like this:

<span id="lblSomePropVal" data-bind="text: MySomeFunction(SomeProperty())" ></span>

What i am trying to do is call MySomeFunction with the value of SomeProperty of my viewmodel. My SomeFunction will return some text based on value passed and that will be displayed in the span lblSomePropVal.

I tried it the way i have written in the example but it throws binding error.

Am i missing something here or is there any other way of doing this?

This is the error i am getting:

Microsoft JScript runtime error: Unable to parse bindings.

Message: [object Error];

Bindings value: text: MySomeFunction(SomeProperty())

Sumit Kesarwani

Total Post:378

Posted on    August-22-2014 2:08 AM

Hi Takeshi, 

<td data-bind="text: $root.MySomeFunction(SomeProperty)"></td>

Don't want to miss updates? Please click the below button!

Follow MindStick