Hi,
I have made some improvements which cause the live filters to work better in IE and to give radiobuttons, drop downs and text boxes a different (and therefore optimized) reaction.
Only thing i'm still not happy about is that when using a text box it will lose it's focus after the live filter is submitted (and you have to click in it again to be able to enter new text).
// $Id: viewslivefilters.js,v 1.1 2009/07/12 20:14:23 ximo Exp $
/**
* @file
* Views Live Filters - Automatically applies exposed filters when changed.
*
* Authors:
* Joakim Stai (http://drupal.org/user/88701)
* Jakob Persson (http://drupal.org/user/37564)
*
* Sponsors:
* SF Bio (http://www.sf.se)
* NodeOne (http://www.nodeone.se)
*/
Drupal.behaviors.viewsLiveFilters = function() {
$('form:has(div.views-exposed-form):not(.viewsLiveFilters-processed)').addClass('viewsLiveFilters-processed').each(function() {
var form = this;
var timeout = undefined;
var delay = 1000;
var delay2 = 100;
// Add throbber to element's label
var throb = function(elem) {
$(elem).after('<span class="views-throbbing"> </span>');
};
// Remove form's submit button.
$(':submit, .submit-button', form).parent().hide();
// Radiobuttons: react on change and click event
$('.views-exposed-widget .form-radio', form).bind('change, click', function() {
if (timeout) {
clearTimeout(timeout);
}
var elem = this;
timeout = setTimeout(function() {
timeout = undefined;
throb(elem);
$(form).submit();
}, delay2);
});
// Drop down's: react on change
$('.views-exposed-widget .form-select', form).bind('change', function() {
if (timeout) {
clearTimeout(timeout);
}
var elem = this;
timeout = setTimeout(function() {
timeout = undefined;
throb(elem);
$(form).submit();
}, delay2);
});
// Submit form after a delay when user types into a text element.
// Doing so will however cause the text box to loose it's focus...
$('.views-exposed-widget .form-text', form).bind('keyup', function() {
if (timeout) {
clearTimeout(timeout);
}
var elem = this;
timeout = setTimeout(function() {
timeout = undefined;
throb(elem);
$(form).submit();
}, delay);
});
});
}