Cannot change class button if using bootstrap

Cannot change class button if using bootstrap

vartavarta Posts: 2Questions: 4Answers: 0

I cannot change class button usin className
For example if I assing the class "btn-primary" this class is added but the "btn-default" class is not removed from the button so the new is never active.
Someone know how to do that ?

Answers

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin

    Could you show me the code you are using or link to a page showing the issue please?

    Allan

  • vartavarta Posts: 2Questions: 4Answers: 0

    The problem is when I use className adding for example "btn-primary" it leaves btn-default so btn-primary is never active.

    I solve it creating a button with
    {
    text: 'Activar',
    className: 'btnLegajo',
    .....
    }

    Then doing

    $(".btnLegajo").removeClass( "btn-default" ).addClass( "btn-primary");

  • JoyrexJoyrex Posts: 92Questions: 14Answers: 3

    By using the className parameter when defining the button, it should add the button class btn-primary (it won't hurt to have btn-default there as well) - I do this as well. There should be no need for the addClass() removeClass() methods.

    Also, I think the reason your code does not work is because you are defining the class applied to the button and then trying to replace it at the same time the dataTable is being rendered (and creating that class).

This discussion has been closed.