This is a migrated thread and some comments may be shown as answers.

Custom binding not working in templates

4 Answers 272 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Luc
Top achievements
Rank 1
Luc asked on 18 Apr 2012, 02:06 AM
Hi,

I've defined a custom binding which works prefectly when used outside templates, but it will not work when used within one.

The binding's refresh function is called in both cases, but when used within a template, this.bindings["bindingName"].get() returns undefined.

Is this a limitation of the curent state of bindings ? Is there a workaround ?

here's the code:

kendo.data.binders.cssClass = kendo.data.Binder.extend({
    refresh: function () {
        var value = this.bindings["cssClass"].get();
 
        $(this.element).removeClass();
        $(this.element).addClass(value);
    }
});

<script id="path-template" type="text/x-kendo-template">
    <li data-bind="click: goToFolder, cssClass: theStyle">#: path #</li>
</script>

Funny thing is that the click binding works within the template...

Thanks

4 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 18 Apr 2012, 05:09 PM
Hello Luc,

I'm afraid that this is currently not supported. However, we may change the observed behavior in feature version.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Joshua
Top achievements
Rank 2
answered on 04 May 2020, 05:22 PM
Is there any work around to this? Is this still being considered as a feature?
0
Aleksandar
Telerik team
answered on 07 May 2020, 01:08 PM

Hello Joshua,

Custom binding can be used within a template. Here is a dojo example demonstrating custom MVVM binding in a template

Let me know if you have further questions.

Regards,
Aleksandar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Joshua
Top achievements
Rank 2
answered on 27 May 2020, 03:56 PM
Thank You
Tags
MVVM
Asked by
Luc
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Joshua
Top achievements
Rank 2
Aleksandar
Telerik team
Share this question
or