Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

"No results" for select2 theme #121

Closed
kanwei opened this issue Jul 25, 2014 · 11 comments
Closed

"No results" for select2 theme #121

kanwei opened this issue Jul 25, 2014 · 11 comments

Comments

@kanwei
Copy link

kanwei commented Jul 25, 2014

select2 supports displaying of a message when there aren't any results. I'm working on a patch to enable this.

`

  • ``

    @teneightfive
    Copy link

    +1

    @dimirc dimirc added this to the 0.7.0 milestone Aug 1, 2014
    @dimirc
    Copy link
    Contributor

    dimirc commented Aug 11, 2014

    Check #152 for possible solution, let me know your opinion

    @dimirc dimirc modified the milestones: 0.8.x, 0.7.x Sep 8, 2014
    @michaeldjeffrey
    Copy link

    Until #152 gets added, I'm using the filter from http://stackoverflow.com/a/23452217/1921234.

    When we get nothing back from the server I add {text: "No Results...", id: ''} to the options.
    And I added this line at the beginning of the filter so it will show up.
    if(input.length == 1 && input[0].text == 'No Results...') return input;

    @MikeABentley
    Copy link

    +1 to this. I'm going to have to see if I can wrap something around the ui-select directive in order to support this throughout my application. It would be great if there was a directive under the ui-select directive that I could define.

    @dimirc dimirc modified the milestones: 0.10.x, 0.8.x Feb 17, 2015
    @caseahr
    Copy link

    caseahr commented Mar 6, 2015

    +1

    1 similar comment
    @junajan
    Copy link

    junajan commented Apr 17, 2015

    +1

    @fabiopaiva
    Copy link

    Alternatively

    <ui-select> 
        <ui-select-match>
            {{$select.selected}}
        </ui-select-match>
        <ui-select-choices repeat="option in options | filter: $select.search" refresh="refreshOptions($select.search)" refresh-delay="500">
            <div ng-bind-html="option | highlight: $select.search"></div>
        </ui-select-choices> 
    </ui-select>
    <div class="text-warning" ng-if="options.length == 0">Nothing found</div>
    

    @nadavsinai
    Copy link

    @fabiopaiva your solution would work only if the options are empty, not when the user search filter makes them empty...+1 for a real solution

    @erikdubbelboer
    Copy link
    Contributor

    @nadavsinai then you shouldn't use a filter but instead do the filtering in your refresh function.

    @fabiopaiva
    Copy link

    @nadavsinai The real solution is always the best

    @wesleycho wesleycho removed this from the 0.10.x milestone Mar 27, 2016
    @wesleycho
    Copy link
    Contributor

    Closing due to the age of the issue - if this is still a problem, please open a new issue with adequate reproduction in Plunker.

    Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests