Changing Button Text Dynamically
Changing Button Text Dynamically
essexsteph
Posts: 57Questions: 0Answers: 0
I'm using DataTables in a project for a large UK local authority and loving it's ease of use and functionality. I'm added some buttons to TableTools to toggle the display of some hidden columns, I'd like to change the text dynamically, i.e. from 'Show Percentages' to 'Hide Percentages', but can't see how to do it - any suggestions or pointers gratefully received.
A donation will be coming your way at some point when the finance department get their head round the concept...
A donation will be coming your way at some point when the finance department get their head round the concept...
This discussion has been closed.
Replies
Allan
I was able to successfully set my custom text using
$(nButton).html('myToggleText');
Now, is there a way to enable/disable the button (so it looks faded/active) based on when I click an external utton elsewhere? (I'm depending on an event not related to DataTables). It seems like I have access to the button node nButton only in the TableTools functions, such as fnInit, fnClick. I don't want the user to be able to click the button until I "activate" it.
Until then its just a case of adding and removing classes. Have a look at the fnSelect functions for the "single_select" button in the TableTools code for example, to see how TableTools itself does it.
Allan
Allan
That is the case yes. I've never been 100% convinced about this particular interaction and I might change it in future, but the idea is that you would be able to flash up a message saying "you need to select a row first", or just ignore the command as you wish (i.e. I wonder if it allows too much flexibility!). In your fnClick function you should check for the disabled class and just return out if it is present.
Allan