Entries Tagged 'JavaScript' ↓

Dynamically parameters in Ajax.Autocompleter

Two days ago I had a problem with Ajax.Autocompleter (from script.aculo.us library). I needed to use dynamically parameters sending in request to the server. Basically they are created only statically when class is set up. To change this behaviour use this solution:

new Ajax.Autocompleter(
    'search',
    'autocomplete_choices',
    'index.php?controller=search&action=autocomplete, {
        paramName: 'name',
        callback: function(element, entry) {
            return entry+"&"+Form.Element.serialize('type');
        }
    }
);