Semantic-Org / Semantic-UI-Angular

Semantic UI Angular Integrations
MIT License
557 stars 117 forks source link

(sm-search) The clicks on a search result, gives no action #65

Closed 120dev closed 7 years ago

120dev commented 7 years ago

Hi,

Thanks for your directive :)

I have a problem with the user to search through the Directive sm-search-bind, research works perfectly well, but when I click the result search, the model is not updated?

Here is the code used :

<div class="ui search" sm-search-bind="
                    {
                      minCharacters: 1,
                      maxResults   : 1000,
                      fields       : {
                        results: 'results',
                        title  : 'libelle',
                        price  : 'ref',
                      },
                      apiSettings  : {
                        url: init.search.article + '/{query}'
                      }
                    }">

                    <input class="prompt"
                           ng-keypress="searchInput($event)" type="text"
                           placeholder="Recherche : Référence ou Article"
                           ng-model="article.article"
                    >

                    <div style="overflow: auto; height:300px; width:450px;font-size: 10px"
                         class="results">

                    </div>
                  </div>

Using the code with sm-search, it works but I manage not retrieve the item when I press the enter key.

<sm-search
                  icon="search"
                  model="article.article"
                  settings="
                  {
                    maxResults : 100,
                    fields : {
                    results     : 'results',
                    title       : 'libelle',
                    price       : 'ref',
                  }}"
                  remote="@{{init.search.article}}/{query}">
                  </sm-search>

Thank you for your help

120dev commented 7 years ago

Okay ... sorry

problem solved by simply using the callback ...

 t.configSearch = {
        onSelect     : function (value) {
          console.log(value);
        },
        minCharacters: 1,
        maxResults   : 1000,
        fields       : {
          results: 'results',
          title  : 'libelle',
          price  : 'ref',
        },
        apiSettings  : {
          url: '/1/search/articles/{query}'
        }
      }

In view :

<div class="ui search" sm-search-bind="configSearch">

                    <input class="prompt"
                           ng-keypress="searchInput($event)" type="text"
                           placeholder="Recherche : Référence ou Article"
                           ng-model="article.article"
                    >

                    <div style="overflow: auto; height:300px; width:450px;font-size: 10px"
                         class="results">

                    </div>
                  </div>