xcash / bootstrap-autocomplete

Bootstrap Autocomplete
MIT License
168 stars 71 forks source link

PreventDefault on with mod_rewrite #51

Closed rejustify closed 4 years ago

rejustify commented 4 years ago

The script works great but when mod_rewrite is on, after selecting an item from the list, the script submits the form by default, redirecting to the next page. It is quite tricky to set preventDefault on the form:

$('.item').autoComplete({   
    resolver: 'custom',
    formatResult: function (item) {
        return {
            value: item.id,
            text:  item.desc + " [" + item.name + "] "
        };
    },
    select: function(e){
        e.preventDefault();
    }
    events: {
        search: function (qry, callback, origJQElement) {
            $.ajax({
                 type: "POST",
                 url: "search.php",
                 data: { 'qry': qry},
                 dataType: "json"
            }).done(function (res) {
                callback(res.results);
            });

        }
    },
}); 
xcash commented 4 years ago

Duplicate of #37