Using AutoComplete inside editor template

2 posts, 0 answers
  1. Paul
    Paul avatar
    24 posts
    Member since:
    Aug 2013

    Posted 04 Sep 2014 Link to this post

    I'm trying to bind kendoAutoComplete to a text element inside the editor template, which I'm doing by inlining some jquery. What I'm finding, though is that the html element appears not to have been rendered into the page at the point where the jquery is running.

    <script id="editor" type="text/x-kendo-template">
            <input id="test" type="text" name="client_name" class="form-control" />
            #$('\#test').kendoAutoComplete(["Item1", "Item2", "Item3"]);#
    </script>
    So the binding doesn't work.

    Is there some way i can do this via an mvvm attribute, or some other way of synchronising the javascript so that I can guarantee the html is rendered at the time when the js is running?

    Cheers, Paul.
  2. Daniel
    Admin
    Daniel avatar
    2224 posts

    Posted 08 Sep 2014 Link to this post

    Hello Paul,

    You can use the data attribute initialization:
    <script id="editor" type="text/x-kendo-template">
        <input id="test" type="text" data-role="autocomplete" data-source='["Item1", "Item2", "Item3"]' name="client_name" class="form-control" />       
    </script>

    or a script tag:
    <script id="editor" type="text/x-kendo-template">
            <input id="test" type="text" name="client_name" class="form-control" />
            <script>
                $('\#test').kendoAutoComplete(["Item1", "Item2", "Item3"]);
            <\/script>
    </script>


    Regards,
    Daniel
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top