2

I have a group of buttons at the moment which users can select to filter out a grid. The problem is that after one of the buttons is clicked, the user does not know the current active filter that was applied. So can anybody help me to figure out how to have these group of buttons act as toggle buttons (spec is to change the button background color for active button)?

Please note this is in MVC and there is an onclick event bound to each of the buttons which calls a javascript function.

0

2 Answers 2

1

If you ar using jquery UI you could try using the button plugin configured as a checkbox

Sign up to request clarification or add additional context in comments.

1 Comment

how to pass for example to controller that B was clicked or not , I mean if I have list of options and I add or remove from it the options according to toggle
1

You haven't given much detail on how you've wired up click events, but in your click handler for the buttons, you could do something like this:

var button = document.getElementById("button");
button.onclick = function() {
    if (!this.style.backgroundColor) {
        this.style.backgroundColor = 'yellow';
    }
    else {
        this.style.backgroundColor = null;
    }
}

There are other ways to do this if you're using jQuery or another JS framework.

Comments

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.