Bootstrap danger class not working for table row

I have the following table in a Rails application:

<table class='table table-bordered table-hover table-striped'> <thead> <tr> <th>ID</th> <th>Status</th> </tr> </thead> <tbody> <tr class='danger'> <td><%= order.id %></td> <td><%= order.status.name %></td> </tr> </tbody> </table> 

And the line with the class "danger" does not change color. However, if I use the success class, it changes correctly.

I use twitter-bootstrap-rails gem.

+7
source share
4 answers

twitter-bootstrap gem currently uses bootstrap v 2.3.2 .

And according to Bootstrap version 2.3.2 Documentation For Tables , the available string classes follow:

 Optional row classes Use contextual classes to color table rows. .success Indicates a successful or positive action. .error Indicates a dangerous or potentially negative action. .warning Indicates a warning that might need attention. .info Used as an alternative to the default styles. 

This is why .success worked, but NOT .danger .

I assume you are looking for a .error class.

+6
source

this seems to be a bug with tables.

It looks like this is a bug in version v3.0.3 and will be fixed in version v3.1.0

send this error error page and this stack question

+6
source

go https://getbootstrap.com/docs/4.3/content/tables/#contextual-classes here they indicated all the classes of rows and cells, you have to change your

 <table class='table table-bordered table-hover table-striped'> <thead> <tr> <th>ID</th> <th>Status</th> </tr> </thead> <tbody> <tr class='table-danger'>//Modified line <td><%= order.id %></td> <td><%= order.status.name %></td> </tr> </tbody> 

+2
source

Maybe you are using the old version for the Bootstrap gem, by the way, by default, the gem was not updated by default to version 3 of Bootstrap, try using this resource

https://github.com/jasontorres/bootstrap-on-rails

As @Kirti said, the correct class for Bootstrap 2 version should be .error instead of .danger see the official documentation:

http://getbootstrap.com/2.3.2/base-css.html#tables

0
source

Source: https://habr.com/ru/post/970007/


All Articles