norixxx
norixxx

Reputation: 3179

jQuery mobile slider bar firing different event depending on its value

Quick question. I use jqmobile ver.1.2.0 with vertical slider plugin(http://www.elmundio.net/blog/jquery-mobile-vertical-slider/).

How do I launch some functions depending on its value. Ex. at value 50, change somewhere else's class name, at value 100 redirect the page to new URL.

I am gonna make some sample page afterwards. Here's sample.

jsfiddle.net/nori2tae/zT2ZH/

Thanks.

Upvotes: 2

Views: 411

Answers (1)

Berker Yüceer
Berker Yüceer

Reputation: 7335

i guess this is what you need

function anotherfunction() {
    alert('another function is fired');
}
$(document).ready(function() {
    //do something
    $('.container').change(function() {
        if ($(this).children('input').val()==50) {
            $('.changeThis').addClass('changed');
            $('.changed').removeClass('changeThis');
            alert("at 50 and changeThis now have [" + $('.changed').attr("class") + "] classes");
        } else if($(this).children('input').val()==100) {
            // another function here
            anotherfunction();
        }
    });
});

jsfiddle: http://jsfiddle.net/BerkerYuceer/5ZHue/

you can also try in mobile debugging mode..

Upvotes: 1

Related Questions