Bootstrap 5.2 tooltip - html

I was trying to use tooltip and show it using jquery on my jquery datatable the problem is the tooltip is not showing.
here's my code:
render: function (data, type, row, meta) {
var total = row.success + row.error;
if (row.isConsumed == true) {
if (total == 100) {
return `<button class="btn btn-sm text-light order-completion" id="order-completion">CONSMUPTIONS</button>`
} else {
return ` <div class="btn-group" role="group" aria-label="GroupButton">
<button class="btn btn-sm text-light order-completion" disabled>CONSUMPTION</button>
<button type="button" class="btn btn-secondary btn-sm"
data-bs-custom-class="custom-tooltip"
data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="top"
data-bs-title="Some title here">
<i class="fa-solid fa-circle-info"></i>
</button>
</div>
`;
//return `<button class="btn btn-sm text-light order-completion" disabled>CONSUMPTION</button>`
}
} else {
return `<button class="btn btn-sm text-light order-completion" disabled>CONSUMPTION</button>`
}
},

Make sure that you have initialized the tooltip feature on your page, by calling:
$('[data-bs-toggle="tooltip"]').tooltip()
after the datatable has been created.
If still doesn't work, check if the element that you want to show the tooltip on is visible when the tooltip is being initialized. If the element is hidden, the tooltip will not be displayed.
And finally, check if the element that you want to show the tooltip on is not inside a container with the property of overflow: hidden or pointer-events: none, as this will also hide the tooltip.

Related

How can I change button color when clicked

To be brief, i have two buttons that have the same class, one of them have an attribute data-toggle='modal'. I use this attribute to detect the button.
I need to change the color of the button which does not have an attribute data-toggle, I can't target it by using the className, because they both have the same.
In the js click function, I use a ternary condition to say: if the button has an attribute 'data-toggle' then do nothing, else removeClass btn--ghost and addClass btn--plain. But it doesn't work.
PS: the btn--plain is the class name used to give the button a bgcolor instead of btn--ghost.
This is the js :
if ($('.o-block-global .btn--link').length) {
$('.btn--primary').on("click", function (e) {
console.log("iiiiii", $(this));
$(this).attr("data-toggle" ? "" : $(this).removeClass("btn--ghost").addClass("btn--plain"));
});
}
This is the HTML :
<div class="o-block-global__links link_choice ">
<button type="button" class="btn btn--ghost btn--primary">
OUI
</button>
<button type="button" class="btn btn--ghost btn--primary" data-toggle="modal" data-target="#modalChoice2">
NON
</button>
</div>
You can check if the attr value is undefined or not using (typeof $(this).attr("data-toggle")) !== 'undefined'
Demo Code :
$('.btn--primary').on("click", function(e) {
//check if the attr type is not undefined
(typeof $(this).attr("data-toggle")) !== 'undefined' ? "" : $(this).removeClass("btn--ghost").addClass("btn--plain");
});
.btn--ghost {
color: red;
}
.btn--plain {
color: blue
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<div class="o-block-global__links link_choice ">
<button type="button" class="btn btn--ghost btn--primary">
OUI
</button>
<button type="button" class="btn btn--ghost btn--primary" data-toggle="modal" data-target="#modalChoice2">
NON
</button>
To do that you use the :active selector. HTML:
<button>Click Me!</button>
button{
background:green;
}
button:hover{
background:lightgreen;
}
button:active{
background:red;
}

Icon in button not registering click event

I have a button with text and a down-arrow icon, which I use to trigger a dropdown. When I click the text part of the button, the dropdown appears, and I have some jquery to amend the text and flip the arrow - great. But when I click the icon part of the button, the text changes and the icon flips but the dropdown doesn't appear.
Do I convert it to an anchor link and change the clickable area, or is there a more simple solution?
HTML
<button type="button" class="btn btn-info button-drop text-nowrap" data-toggle="collapse" data-target="#ph-detail" aria-expanded="false" aria-controls="ph-detail">See More
<i class="bi bi-arrow-down"></i>
</button>
<div class="collapse" id="ph-detail">
<p>Expandable content</p>
</div>
JQuery
$('.button-drop').click(function() {
$(this).toggleClass( "active" );
if ($(this).hasClass("active")) {
$(this).html('See Less <i class="bi bi-arrow-up">');
} else {
$(this).html('See More <i class="bi bi-arrow-down">');
}
});
Both of the code are working for me. I think you have not added the cdnjs file of jQuery
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
$('.button-drop').click(function() {
$(".button-drop").toggleClass( "active" );
if ($(".button-drop").hasClass("active")) {
$(".button-drop").html('See Less <i class="bi bi-arrow-up">');
} else {
$(".button-drop").html('See More <i class="bi bi-arrow-down">');
}
});
$('.button-drop').click(function() {
$(this).toggleClass( "active" );
if ($(this).hasClass("active")) {
$(this).html('See Less <i class="bi bi-arrow-up">');
} else {
$(this).html('See More <i class="bi bi-arrow-down">');
}
});
In the end I solved it with the following:
<button type="button" class="btn btn-info button-drop text-nowrap" data-toggle="collapse" data-target="#ph-detail" aria-expanded="false" aria-controls="ph-detail"><span>See More </span>
<i class="bi bi-arrow-down"></i>
</button>
$('.button-drop').click(function() {
$(this).find('i').toggleClass('bi bi-arrow-up');
$(this).find('span').text(function(a, text) {
return text === "See More " ? "See Less " : "See More ";
});
});

How to Minimize ngx-bootstrap Accordion box?

I have an accordion in Html
<accordion [isAnimated]="true">
<accordion-group heading="Date Created">
{{ example text }}
</accordion-group>
</accordion>
I want to reduce the size of the box, text and the text when clicked. Basically reduce the size of entire box. How to do that?
I have tried these below which reduce the Header text and body text but not the box
<accordion-group panalClass="xyz">
<button
class="btn btn-link btn-block clearfix"
accordion-heading
type="button" panalClass="xyz"
>
<div class="pull-centre float-centre" style="background-color: blue;">
Date Created
</div>
</button>
{{ example text }}
</accordion-group>
I want to align the element with rest of the page.
Since I didnt find an option to resize it I found out that I have to use the angular generated classes (Shadow CSS concept) which can be seen in the elements section in console page. In this case it was ".panel-heading" and ".panel-body".
Use the angular class within your own class to make the effect IN styles.css to get the effect. Like this:
.accordion-small {
.panel-heading {
padding: 0px;
}
}
.accordion-small {
.panel-body {
padding: 5px;
font-size: small;
text-align: center;
}
}
In html:
<accordion [isAnimated]="true" class="accordion-small">
<accordion-group>
<button
class="btn btn-link btn-block clearfix"
accordion-heading
type="button"
>
<div class="pull-centre float-centre header-name">
Date Created
</div>
</button>
{{ example text }}
</accordion-group>
</accordion>
In component css
.header-name {
font-size: small;
}
Result:
Another way is you can use [panelClass]="customClass" to define the custom styling for your ngx-bootstrap accordion.
In css:
.custom-accordion-style {
/*any size you want*/
line-height: 30px;
font-size: small;
}
In ts:
customClass='custom-accordion-style';
In html:
<accordion [isAnimated]="true">
<accordion-group [panelClass]="customClass">
<button class="btn btn-link btn-block clearfix"
accordion-heading
type="button">
<div class="pull-centre float-centre">
Date Created
</div>
</button>
{{ example text }}
</accordion-group>
</accordion>

How to change color of bootstrap glyphicon?

I want to change bootstrap glyphicon color to "yellow" because current color is showing in white that looks like Delete button. How can i change color of glyphicon-folder-close or use any other glyphicon that display folder image better ?
main.html
<button type="button" class="btn btn-info btn-lg" ng-click="serverFiles()" style="margin-left: 10px"><span class="glyphicon glyphicon-folder-close"></span></button>
You can also change the icon/text by adding to the class "text-success" for green, "text-danger" for red etc. This will change the color of the icon itself.
<span class="glyphicon glyphicon-usd text-success"></span>
Also this has been answered here.
Change the color of glyphicons to blue in some- but not at all places using Bootstrap 2
Use color
<button type="button"
class="btn btn-info btn-lg" ng-click="serverFiles()"
style="margin-left: 10px; color:#FF0000;">
<span class="glyphicon glyphicon-folder-close"></span></button>
But remember that it is desirable to avoid the use of inline style is better use classes or references based on external css configuration items
<button type="button"
class="btn btn-info btn-lg mybtn-blue" ng-click="serverFiles()"
style="margin-left: 10px;">
<span class="glyphicon glyphicon-folder-close"></span></button>
edn for external css
.mybtn-blue {
color: blue;
}
Use the following HTML code
<button type="button" class="btn btn-info btn-lg" ng-click="serverFiles()" style="margin-left: 10px"><span class="glyphicon glyphicon-folder-close yellow"></span></button>
And the css code
.yellow {
color: #FFCA28;
}
here is the demo http://jsfiddle.net/S3R23/1217/
You can change color of the icon by directly specifying color name, however this will only apply to targeted icon.
To change the color, do this:
<span class="glyphicon glyphicon-folder-close" style="color:#ffff00"></span>
Just edit the span tag in your code to the one above, making your code to look like this:
<button type="button" class="btn btn-info btn-lg" ng-click="serverFiles()" style="margin-left: 10px"><span class="glyphicon glyphicon-folder-close" style="color:#ffff00"></span></button>
You can change glyphicon color to any value. see below given example
<span aria-hidden="true" class="glyphicon form-control-feedback glyphicon-ok"></span>
//css
.glyphicon.form-control-feedback.glyphicon-ok{
color: #20032d !important;
}

Bind click event to disabled link in Twitter Bootstrap

HTML:
<a id="foo" href="#" class="btn btn-default btn-lg disabled" role="button">Link</a>
<a id="bar" href="#" class="btn btn-default btn-lg" role="button">Link</a>
jQuery:
$("#foo,#bar").click(function(e){
e.preventDefault();
alert('click');
});
The alert appears when clicking #bar, but not when clicking #foo. How can I fix this?
Fiddle: http://jsfiddle.net/VVw8S/
In Bootstrap you can read this code:
.btn.disabled, .btn[disabled], fieldset[disabled] .btn {
pointer-events: none;
}
If you want to have a disabled button which allowed click events, just overwrite this CSS with pointer-events: inherit;. Or simply remove disabled in the class of your first link.