Setting a button color (getting different behavior depending on script file used)

Setting a button color (getting different behavior depending on script file used)

JackTrickJackTrick Posts: 3Questions: 1Answers: 0
edited January 2020 in Free community support

example here:
http://live.datatables.net/yonakowu/346/edit

I'm trying to set the color of a button by setting its class (btn-primary).

I noticed that regardless of what I did, the button was still showing up as grey. When I checked to see what the button class was when live, it was showing as "btn-secondary btn-primary"

I saw other examples of what I was doing working, and eventually found the behavior changed depending on the datatables compiled script I was using.

If I used:
script type="text/javascript" src="https://cdn.datatables.net/v/bs-3.3.7/jszip-2.5.0/dt-1.10.18/b-1.5.2/b-html5-1.5.2/b-print-1.5.2/datatables.min.js"
it worked as expected

If I used:
script type="text/javascript" src="https://cdn.datatables.net/v/bs4-4.1.1/dt-1.10.20/b-1.6.1/b-colvis-1.6.1/fc-3.3.0/sc-2.0.1/sp-1.0.1/datatables.min.js"
it kept the button as grey (dual class defined?)

Is there something I'm doing incorrectly? Is this just some odd side-effect of the blend of scripts I'm referencing? Is there some other way I can set the button color? Perhaps through direct editing of the style?

This question has an accepted answers - jump to answer

Answers

  • JackTrickJackTrick Posts: 3Questions: 1Answers: 0
    edited January 2020

    wrong link posted, corrected

  • ITAppData@HomeStreet.comITAppData@HomeStreet.com Posts: 54Questions: 13Answers: 2
    edited January 2020 Answer ✓

    I accomplish it by giving the button a className and then in the initComplete function I do:

    $(".className").removeClass("btn-secondary").addClass("btn-primary");
    

    You have to remove the "btn-secondary" class and add the class you want.

    I suppose you could also do:

    $(".btn-primary").removeClass("btn-secondary");
    
  • JackTrickJackTrick Posts: 3Questions: 1Answers: 0

    Cheers! That worked around the issue. Thanks!

  • dnepomuceno101dnepomuceno101 Posts: 31Questions: 4Answers: 0

    where did you change that ? can u please send a pic or code

This discussion has been closed.