Custom binding not working in templates

5 posts, 0 answers
  1. Luc
    Luc avatar
    42 posts
    Member since:
    Jul 2012

    Posted 17 Apr 2012 Link to this post

    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
  2. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 18 Apr 2012 Link to this post

    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!
  3. Joshua
    Joshua avatar
    2 posts
    Member since:
    Oct 2016

    Posted 04 May 2020 in reply to Rosen Link to this post

    Is there any work around to this? Is this still being considered as a feature?
  4. Aleksandar
    Admin
    Aleksandar avatar
    280 posts

    Posted 07 May 2020 Link to this post

    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.
  5. Joshua
    Joshua avatar
    2 posts
    Member since:
    Oct 2016

    Posted 27 May 2020 in reply to Aleksandar Link to this post

    Thank You
Back to Top