chifailai2 / jquery-datatables-column-filter

Automatically exported from code.google.com/p/jquery-datatables-column-filter
0 stars 0 forks source link

Jquery UI Slider not working as range input #32

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

I am using the following code to draw a JqueryUI slider which updates the 
values in two input boxes as shown below:-

//SLIDER

$(function() {
    var $slider = $('#Slider'),
    $lower = $('input#Min'),
    $upper = $('input#Max'),
    min_rent = 0,
    max_rent = 400;

$lower.val(min_rent);
$upper.val(max_rent);

$('#Slider').slider({
    orientation: 'horizontal',
    range: true,
    animate: 200,
    min: 0,
    max: 400,
    step: 1,
    value: 0,
    values: [min_rent, max_rent],
    slide: function(event,ui) {
        $lower.val(ui.values[0]);
        $upper.val(ui.values[1]);
    }
});

$lower.change(function () {
    var low = $lower.val(),
        high = $upper.val();
    low = Math.min(low, high);
    $lower.val(low);
    $slider.slider('values', 0, low);
});

$upper.change(function () {
    var low = $lower.val(),
high = $upper.val();
    high = Math.max(low, high);
    $upper.val(high);
    $slider.slider('values', 1, high);
});

});

What is the expected output? What do you see instead?

When binding the update to input#Min and input#Max the input values update 
correctly.

However, if I set those to the two input boxes that are created by your plugin 
for Datatables, nothing happens.

I expected the Datatable to filter.

Please provide any additional information below.

Essentially I am just trying to use a slider to control the range filtering of 
my datatable.  If you know of any solution whatsoever I would be most grateful

Original issue reported on code.google.com by gordonrankin82@gmail.com on 29 Sep 2011 at 4:10

GoogleCodeExporter commented 8 years ago
Hi,

It seems to me that changing the value do not triggers filter.

in the line 129 of plugin you can see that filtering is done on "keyup" event
$('#' + sFromId + ',#' + sToId, th).keyup(function () {

Maybe you can fire this event on the input box  something like a 
$upper.fire('keyup')

Jovan

Original comment by joc...@gmail.com on 29 Sep 2011 at 5:58

GoogleCodeExporter commented 8 years ago
I've actually just solved the issue... I realised that the filtering wasn't 
taking place because the inputs wee'nt present in the dom at the time since 
they are generated dynamically by datatables/Columnfilter.

The livequery plugin did the trick.

Original comment by gordonrankin82@gmail.com on 29 Sep 2011 at 6:23

GoogleCodeExporter commented 8 years ago
Great, I;m glad that you have fixed this.

Jovan

Original comment by joc...@gmail.com on 29 Sep 2011 at 11:24