Buttons - How to click/un-click
Buttons - How to click/un-click
jLinux
Posts: 981Questions: 73Answers: 75
Im just trying to use the buttons extension, with a collection of buttons, and I was wondering how I could make it so when you click on a button, it performs an action and stays "pressed", then you can un-click it, and it will perform another action, and then display as an un-clicked button. Heres an example with the column visibility plugin
So just 2 questions..
- How do I make it so it stays pressed?
- How do I tell in the JS if its being clicked or un-clicked? Do I just have to hold the state of the button in memory and reference that every time? (hoping theres a more elegant way)
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I kinda hacked it to just use the
active
class as the status, JSBinIm not sure its the right way, if it isn't, let me know, if it is... let me know :)
The
button().active()
method is probably the one you want here. Oddly, it appears it can't be used as a getter in the current release, so I've just added that and its in the nightly now (will be in the 1.1.1 release).Here is how you can do it with that modification: http://live.datatables.net/pinekusi/1/edit .
Allan
@allan, thanks! Im not sure how I overlooked the
button().active()
, my bad.How can I get that to work for buttons in a collection? I tried both approaches in the documentation, neither seem to work.
http://live.datatables.net/jewuqegu/1/edit?js,output
It won't work with the 1.0.1 release of buttons which you had in that bin. It needs the nightly: http://live.datatables.net/jewuqegu/2/edit .
Allan