Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Typehead value disappear when clicked on result #1529

Open
aniket-singh opened this issue Jun 10, 2016 · 1 comment
Open

Typehead value disappear when clicked on result #1529

aniket-singh opened this issue Jun 10, 2016 · 1 comment

Comments

@aniket-singh
Copy link

I have used typehead in my page everything is working perfectly fine but when i click on the result the value get disappear from search

to make you better understand see the screenshot

screenshot_18

Now when i click on names the value abhishek verma will dissappear from search input.

here is my jquery

  `if($('.typeahead').length){
   var repos;
    repos = new Bloodhound({
            datumTokenizer: function(d) { return d.tokens; },
            queryTokenizer: Bloodhound.tokenizers.whitespace,
            remote: {
            'cache': false,
            url: '/ajax/search_json.php?q=%QUERY',
            wildcard: '%QUERY',
            filter: function (data) {
            return data;
            }
            }
        });

 repos.initialize();

 $('.typeahead').typeahead(null, {
 name: 'typeahead-sample',
 source: repos.ttAdapter(),
 templates: {
         empty: [
             '<div class="empty-message">',
                'unable to find your type that match the current query', '</div>'
              ].join('\n'),
              suggestion: Handlebars.compile([
             '<a href="javascript:void(0);" class="media border-dotted animated fadeIn">',
               '<span class="media-object pull-left">',
               '<img src="//cdn.twkcdn.com/profile/image/{{img}}?w=40&h=40&cf">',
                    '</span>',
                    '<span class="media-body">',
                    '<span class="media-heading">{{name}}</span>',
                    '<span class="media-text">{{phone}}</span>',
                    '</span>',
                    '</a>'
                ].join(''))
            }
        });
    }`

What could be wrong in jquery function?

@laCour
Copy link

laCour commented Jul 6, 2016

See my comment here: #1408 (comment)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

2 participants