1

I am having problems updating the ui jquery slider when a select is changed or input is changed - anyone have any ideas on the source to resolve this?

$('.application-progress').slider({
    range: "min",
    min: 0,
    max: 100,
    animate: true,
    slide: function(event, ui){
        $("#progress").html(ui.value+"%");
    }
});
$("#progress").html($(".application-progress").slider("value")+"%");

$('input').focusout(function(){
    var percentage = 0;
    $('input').each(function(){
        if($(this).val() != "")
            percentage += 10;
    });
    $("#progress").slider({value: percentage});
    $("#progress").html($(".application-progress").slider("value")+"%");
});​

I have added to jsfiddle: http://jsfiddle.net/Ykx5f/1/.

VisioN
  • 143,310
  • 32
  • 282
  • 281
James Brandon
  • 1,350
  • 3
  • 16
  • 43

2 Answers2

0

I have updated your fiddle. Attach to the change event rather than the focusout/blur.

Konstantin Dinev
  • 34,219
  • 14
  • 75
  • 100
0

Is that you are trying to achieve?

$("input, select").change(function() {
    var percentage = 0;
    $('input, select').each(function() {
        if ($.trim(this.value) != "") percentage += 10;
    });
    $(".application-progress").slider("value", percentage);

    $("#progress").html(percentage + "%");
});​

DEMO: http://jsfiddle.net/Ykx5f/9/


And here is the updated version, which automatically calculates the percentage based on the number of input fields:

$("input, select").change(function() {
    var fields = $("input, select");
    var percentage = 100 * fields.filter(function() {
        return $.trim(this.value) != "";
    }).length / fields.length;

    $(".application-progress").slider("value", percentage);
    $("#progress").html(percentage + "%");
});​

DEMO: http://jsfiddle.net/Ykx5f/11/

VisioN
  • 143,310
  • 32
  • 282
  • 281