dzordz
dzordz

Reputation: 2317

Jquery Bootstrap TouchSpin plugin and update/reset of one option

So I've found a awesome jquery plugin which fits with Bootstrap 3 called TouchSpin. It adds a - and + sign in each side of input and you can control number inside that input with two buttons.

I've tried to update one of settings in TouchSpin, the max value, with on click to some example button.

You can try and edit example here: http://jsfiddle.net/g8M9g/

I've added a variable before everything and I try to change that variable on click to button. The value in input changes but the max option stays at the old value.

Do anyone now how could be possible to update value for max option?

script:

var maxLL = 100;

$( ".update" ).on("click",function(){
    maxLL = 90;
    $( ".ex_limit" ).val(maxLL - 1);

});

$( ".ex_limit" ).TouchSpin({
    min: 1,
    max: maxLL,
    mousewheel: true,
    stepinterval: 50,
    maxboostedstep: 10000000,
});

html:

<div class="container">
<input id="ex_limit" name="ex_limit" type="text" class="ex_limit form-control" value="99"/>
    <br/>
    <br/>
    <button class="update btn btn-primary btn-xs">Update</button>
</div>

any suggestion or advice is welcome

Upvotes: 2

Views: 10402

Answers (1)

There is a new version of the plugin, in which you can update a setting with the following code:

$("input").trigger("touchspin.updatesettings", {max: 1000});

I have updated the fiddle with the newer version and modified it so it is now updating the max value on click.

Upvotes: 8

Related Questions