New issue

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

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

Already on GitHub? Sign in to your account

Duplicate filters in dropdown #297

Closed
Vinzoof opened this Issue Feb 14, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@Vinzoof

Vinzoof commented Feb 14, 2017

Hi @running-coder,
I'm trying to set a dropdownFilter relying on the source groups. I encounter an issue : all the filters are duplicated (see below).

Heberger image

Here is my code :

$.typeahead({
    debug: true,
    input: '.js-typeahead',
    minLength: 2,
    maxItem: 10,
    maxItemPerGroup: 4,
    searchOnFocus: true,
    accent: false,
    order: null, //à laisser à null pour ne pas modifier l'ordre de l'historique
    hint: false,
    cache: true,
    compression: true,
    generateOnLoad: true,
    display: ["code", "libelle"],
    dropdownFilter: "Tout CASSINI",
    href: "{{url}}",
    template: function (item) {
        var groupName = item.group;

        var result = '<span>' +
            '<span class="group">{{concept}} </span>' +
            '<span class="hexaidabs">{{hexaidabs}} </span>' +
            '<span class="code">({{code}}) </span>' +
            '<span class="libelle">{{libelle}}</span>' +
            '<span class="logo">' +
            '<img src="/assets/jquerytypeahead/img/hockey_v1/{{img}}.gif">' +
            '</span>' +
            '</span>';
        return result;
    },
    correlativeTemplate: true,
    source: {
        "mes derni\350res recherches": {
            data: function () {
                if (typeof Cookies.getJSON('CASSINISearchHistory') != "undefined") {
                    return Cookies.getJSON('CASSINISearchHistory')
                }
                else {
                    return []
                }
            }
            //dynamic:true //NE FONCTIONNE PAS
        },
        "Urbanisme": {
            url: "data/urba.json"
        },
        "Applications": {
            url: "data/apps.json"
        },
        "Mod\350le m\351tier d'entreprise": {
            url: "data/mme.json"
        },
        "Bases de donn\351es": {
            url: "data/bdds.json"
        },
        "Services et pivots": {
            url: "data/pfs.json"
        },
        "Technologies": {
            url: "data/tecs.json"
        }
    },
    callback: {
        onShowLayout: function (node, query) {
            console.log("onShowLayout");
        },
        onNavigateBefore: function (node, query, event) {
            event.preventInputChange = true; // on ne met pas à jour le champ input lorsqu'on navigue dans la liste des résultats

            if (~[38, 40].indexOf(event.keyCode)) { //flèches haut et bas

            }
            //bouton enter -> equivalent d'un click
            if (event.keyCode === 13) {
                window.location.href = $('.typeahead__item.active a:first').attr("href")
            }
        },
        onClickBefore: function (node, a, query, event) { //cas du clic sur un élément proposé -> on atteint la page ou ou lance une recherche classique selon le cas
            //console.log(node);
        },
        onSubmit: function (node, form, item, event) { //cas du lancement de la recherche sur un terme -> on lance une recherche classique
            query = $(this)[0].query;
            alert("lancement d'une recherche sur le terme (webservice) : " + query);
            addToSearchHistory(query);
//debugger;			
        }

    }
});

Any idea ? :-)

@running-coder

This comment has been minimized.

Owner

running-coder commented Feb 14, 2017

hey @Vinzoof no idea, never seen that... can you replicate using latest commit on develop? 144d15e6b8d1de235892d6fbb30447ffe455f3bd. I still have a TODO in the code to verify the dropdownFilter option, will verify that at the same time

@running-coder

This comment has been minimized.

Owner

running-coder commented Feb 15, 2017

Found the issue, fix will be coming shortly. I'm adding a bunch of tests with it.

@running-coder running-coder added the Bug label Feb 15, 2017

@running-coder running-coder added this to the 2.8.0 milestone Feb 15, 2017

running-coder added a commit that referenced this issue Feb 15, 2017

@running-coder

This comment has been minimized.

Owner

running-coder commented Feb 15, 2017

Thanks for flagging the issue, it should be resolved now! lmk

@Vinzoof

This comment has been minimized.

Vinzoof commented Feb 16, 2017

It works perfectly now ! Thank you 👍

running-coder added a commit that referenced this issue Mar 1, 2017

Version 2.8.0

Features

- #302 `cache`, `compression` and `ttl` can now be configured at group level
- #299, #304 Add `templateValue` option
- #280 Default suggestions, added suggestion_v1 demo
- #275 Dynamic sources, each groups can now be configured to be `dynamic: true`
- #284 Added option `blurOnTab` to blur Typeahead when "Tab" key is pressed
- #262 Add `onDropdownFilter` callback
- Add `maxLength` option

Fixes

- #297 Duplicated entries in dropdown filters
- #286 Using dynamic, groupOrder and groupTemplate options, the results are empty after the second search
- #285 "undefined" is appearing in the template when a key is not defined instead of empty string
- #283 issue when Ajax `path` config is left blank
- #281 multi level deep data inside the source objects
- #274 onCancel event
- #270 Hide autocomplete suggestions when text input loses focus

running-coder added a commit that referenced this issue Mar 1, 2017

Version 2.8.0
Features
- #302 `cache`, `compression` and `ttl` can now be configured at group level
- #299, #304 Add `templateValue` option
- #280 Default suggestions, added suggestion_v1 demo
- #275 Dynamic sources, each groups can now be configured to be `dynamic: true`
- #284 Added option `blurOnTab` to blur Typeahead when "Tab" key is pressed
- #262 Add `onDropdownFilter` callback
- Add `maxLength` option

Fixes
- #297 Duplicated entries in dropdown filters
- #286 Using dynamic, groupOrder and groupTemplate options, the results are empty after the second search
- #285 "undefined" is appearing in the template when a key is not defined instead of empty string
- #283 issue when Ajax `path` config is left blank
- #281 multi level deep data inside the source objects
- #274 onCancel event
- #270 Hide autocomplete suggestions when text input loses focus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment