pawelczak / EasyAutocomplete

JQuery autocomplete plugin
http://easyautocomplete.com
MIT License
729 stars 244 forks source link

Redirecting based on suggestion list #458

Open saravanamani1999 opened 3 years ago

saravanamani1999 commented 3 years ago
var options = {
    url: "https://saravanamani1999.github.io/api/moduleInfo.json",

    getValue: "moduleCode",

    adjustWidth: false,

    template: {
        type: "description",
        fields: {
            description: "title"
        }

    },

    list: {
        maxNumberOfElements: 10,
        match: {
            enabled: true
        },
        showAnimation: {
            type: "slide", //normal|slide|fade
            time: 300,
            callback: function() {}
        },

        hideAnimation: {
            type: "slide", //normal|slide|fade
            time: 300,
            callback: function() {}
        },
        onClickEvent: function(event, ui) {
            // alert("click");
            location.href = "http://localhost:3000/modules/" + moduleCode
        }
    },
    theme: "round"
};

`$("#search-bar").easyAutocomplete(options);

Hi, im currently trying to redirect my webpage based on the suggestion list based on my json api. So onClickEvent, i want it to redirect to the "http://localhost:3000/modules/" followed by the item clicked which is moduleCode. Any help would be much appreciated. Cheers!