1

I'm using jQuery Toggles plugin: https://github.com/simontabor/jquery-toggles

Here's my code:

$(function(){
    $('.toggle').toggles({        
        clicker:'.i-am'
    });
    $('.i-am').click(function(){
        if ($(this).hasClass('active')){
            return false; /* And it doesn't stop the toggling */
        }        
    });
});

As you see, I want to disable toggling, when clicking on .i-am.active. But return false; doesn't do the trick. How can I achieve this?

Update. Created jsfiddle to make it clear: http://jsfiddle.net/webstyle/fBpvb/

3
  • 1
    Can you post some HTML? Commented Nov 29, 2013 at 10:56
  • 1
    Can you post a bit more code & details? Commented Nov 29, 2013 at 11:15
  • Added jsfiddle example to make it clear. Commented Nov 30, 2013 at 9:30

1 Answer 1

1

Try this:

http://jsfiddle.net/ydBm2/1/

$(function(){
    $('.i-am').click(function(e){
        if ($(this).hasClass('active')){
            e.stopImmediatePropagation();
            return false; /* This line doesn't work */
        }
        else {
            $('.i-am').removeClass('active');
            $(this).addClass('active');
        }
    });
    $('.toggle').toggles({
        drag:false,
        click: false, 
        text:{on:'',off:''},
        clicker:'.i-am'
    });
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. return false; is not needed now, I think.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.