Select event not firing with Angular directives

4 posts, 0 answers
  1. Tim
    Tim avatar
    8 posts
    Member since:
    Nov 2012

    Posted 11 Aug 2014 Link to this post

    I can't figure out why the select even is not firing.  Consider the directives below and associated javascript even wiring.   Please advise.

    <input id="customerSearch" placeholder="Search Customer"
                               kendo-auto-complete
                               k-suggest="true"
                               k-height="100"
                               k-data-text-field="'name'"
                               k-data-source="customerSearchDataSource"
                               ng-model="search"
                               k-template="'<span>${ data.name }</span>'">

     $(function () {
                $("#customerSearch").kendoAutoComplete({
                    select: function (e) {
                        var item = e.item;  // never hits here.
    ...

                    }
                });
  2. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 11 Aug 2014 Link to this post

    Hello Tim,

    The angular directives will initialize the widget - there is no need to do it again with the jQuery plugin syntax. You may use the directive attributes to wire up the event handlers, like our documentation describes

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Tim
    Tim avatar
    8 posts
    Member since:
    Nov 2012

    Posted 11 Aug 2014 Link to this post

    Yes, a bit better now.  However, I don't know how to get a handle to the data item.  It seems you can only get the dataItemTest NOT the dataItem itself using the ng-model.  I need the dataItem to I can get the "id" field not the text that was selected.

    $scope.autocomplete_select = function (e) {
                    var text = $scope.search; // HOW TO GET THE DATA ITEM ??
                }

  5. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 12 Aug 2014 Link to this post

    Hi Tim,

    the autocomplete does not expose such method by design since it accepts unrestricted user input. The user may enter a text which does not match any of the data items; so implementing features relying on the matching dataItem is not recommended. In case you want to limit your users' choice to a list of pre-defined options, you may use the dropdownlist or the combobox widgets.

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