jswolf
jswolf

Reputation: 130

Jquery Smartspinner Reset Value

i use Jquery Smartspinner it's work fine but i can't reset the value in the function onload i set initValue:3 when i set are new value in the smartspinner box he dont override the new value he set the old initValue in

thats the plugin

var duration = $("#bookingduration").spinit({ height: 18, width: 65, min: 1, initValue: 3, max: 62 });

now i have are calender and send the new duration in the box

$('#cdateto').datepicker({
dateFormat: 'dd.mm.yy',
minDate: $('#cdatefrom').datepicker('getDate'),
onSelect: function () {
    // diff
    var d1 = $('#cdatefrom').datepicker('getDate');
    var d2 = $('#cdateto').datepicker('getDate');
    var diff = 0;
    if (d1 && d2) {
        diff = Math.floor((d2.getTime() - d1.getTime()) / 86400000);
    }
            duration.reset(diff);
            $("#bookingduration").val(diff);
 }
});

when the diff now 10 is and i press the key up or down then he load the old initvalue 3 i have trails withe are jquery val override but it does not work

Upvotes: 1

Views: 268

Answers (2)

Praveen
Praveen

Reputation: 56509

From Docs:

Smart Spin plugin has a “reset” method that can be invoked over the plugin, “reset” method takes one parameter, the plugin value will be updated by this parameter value.

Upvotes: 1

Tommi
Tommi

Reputation: 3247

If I properly deciphered your English, you need to store widget to variable:

var spinner = $("#bookingduration").spinit({ height: 18, width: 65, min: 1, initValue: 3, max: 62 });

And call method reset when you need:

spinner.reset(diff)

Upvotes: 2

Related Questions