Set two elements, modal and popover, in data-toggle - button

I'm facing a problem with getting a button to open a popver modal when hovering over and click.
<button type="button"
class="btn btn-success btn-lg"
data-target="#addChangeModal"
data-toggle="####"
data-toggle=""
data-content="Add change">
</button>`
when I set data-toggle to
data-toggle="modal"
or
data-toggle="popover"
Both values modal and popover work perfectly.
However I am unable to set
data-toggle="modal popover"

The official answer to this from the Devs of Bootstrap:
Don't use data attributes from multiple plugins on the same element. For example, a button cannot both have a tooltip and toggle a modal. To accomplish this, use a wrapping element.
An example of this would be something like:
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
<span data-toggle="tooltip" title="Tooltip Message">Data<span>
</a>
credit to: Bootstrap: Collapse and Tooltip together

Launch your modal with jQuery:
$('#my-btn').click(function () {
$('#addChangeModal').modal('show');
$('[data-toggle=popover]').popover('hide'); //EDIT: added this line to hide popover on button click.
});
And then use a standard popover from Bootstrap, include data-trigger="hover" to show popover on hover.
<button id="my-btn" type="button" class="btn btn-success btn-lg" data-trigger="hover" data-original-title="Popover Title" data-content="Popover content" data-toggle="popover"></button>
Bootply Demo

Related

How to load Partial View inside Button Popover?

I am trying to display a partial view inside a button popover.
cshtml:
<button type="button" class="btn btn-secondary" data-container="body"
data-toggle="popover" data-placement="bottom" id="popoverBtn"
data-content="#(await Html.PartialAsync("_ListBoxPartial"))">
Popover on bottom
Partial View:
<div class="row">
<div class="col-12">
<select name="test" style="width:100%;" id="selectMultiple" class="form-control custom-select" multiple>
<option>123</option>
<option>456</option>
<option>789</option>
</select>
</div>
</div>
But it displays like this:
Instead of using RenderPartialAsync, use PartialAsync
<button type="button" class="btn btn-secondary" data-container="body"
data-toggle="popover" data-placement="bottom" id="popoverBtn"
data-content="#(await Html.PartialAsync("_ListBoxPartial"))">
Popover on bottom
</button>
If you are initializing your popover via javascript, the v4 documentation of bootrap states:
html (boolean property with a default of false): Insert HTML into
the popover. If false, jQuery's text method will be used to insert
content into the DOM. Use text if you're worried about XSS attacks.
I haven't tried it but there might also be a data attribute equivalent of data-html="true" if you are not using js to initialize the popover (it would seem odd if there is though).

Create space between an icon and text label in a button

Hi have buttons on my website that could have material icons inside (left or right). For example:
<button class="btn btn-primary">
Button Label
</button>
<button class="btn btn-primary">
Button Label
<span class="material-icons-outlined"> settings </span>
</button>
<button class="btn btn-primary">
<span class="material-icons-outlined"> settings </span>
Button Label
</button>
As you can see, icon could be present or not and in case is present, it could be before or after text.
I'd need to "space" this icon from text, but I can't simply apply margin:0 20px to it because I'd need to create space only between text and icon and from icon to button side.
I thought that a possible solution could be wrap text label in another span to target it and then use :first-child or :last-child to target icon but... if could be possible to not add this wrap could be ideal.
<button class="btn btn-primary">
<span>Button Label</span>
<span class="material-icons-outlined"> settings </span>
</button>
.material-icons-outlined:last-child {
margin-left: 20px;
}
Did you try giving text an id and icon an id, then providing a margin? Just a thought. I believe you can also wrap it as you mentioned. Flexbox might be worth a go as well.

Angular 4 change css by id

I am trying to change CSS property by element ID using vanilla JS?
I am trying to achieve the following effect:
After the first button is clicked on the bottom bottom, the first button on the top should change it's class from btn-dark to btn-warning.
The remaining buttons should follow this same pattern: #b2 clicked should result in #d2 being changed from btn-dark to btn-warning.
My current attempt:
<div class="row">
<button *ngFor="let number of [1,2,3,4,5,6,7,8,9,10]"
type="button"
class="btn btn-dark"
id="d{{number}}"
>
</button>
</div>
<div class="row">
<button (click)="onClick($event)"
*ngFor="let number of [1,2,3,4,5,6,7,8,9,10]"
type="button"
class="btn btn-secondary"
id="b{{number}}">{{number}}
</button>
</div>
Screenshot displaying the template
Use ngClass, e.g.:
<button [ngClass]="{'btn-dark': true}">...</button>
Try like this
it will changed one of them at a time
stackblitz demo link

Bootstrap Footer Modal Spacing not working in React.js

I am trying to add a space between these two buttons, So I used bootstraps modal-footer class and I believe the buttons were supposed to have space in between, but there is no spacing. My code is below:
< div className = "modal-footer">
<Button bsStyle = "primary pull-right" formNoValidate={true} type="submit">Submit</Button>
<Button bsStyle = "default pull-right" onClick={this.resetForm} type="reset">Reset</Button>
</div>
The white-spaces between your JSX tags are not kept once the JSX is compiled to javascript. If you want to keep them anyway, you can do this:
<Button bsStyle = "primary pull-right" formNoValidate={true} type="submit">Submit</Button>
{' '}
<Button bsStyle = "default pull-right" onClick={this.resetForm} type="reset">Reset</Button>
Put them inside 'btn-toolbar', not 'modal-footer'. The .modal-footer class is used to define the style for the footer of the modal. For .btn-toolbar class see more info on Bootstrap documentation.
Try this code:
<div className="btn-toolbar">
<button className="btn btn-primary pull-right" formNoValidate={true} type="submit">Submit</button>
<button className ="btn btn-primary pull-right" onClick={this.resetForm} type="reset">Reset</button>
</div>
Please note: I have used 'button' html tag NOT 'Button' of bootstrap. That's why I have changed the bsstyle to className. You can try on your bootstrap setup.
There are other css methods also using which you can provide space between buttons easiest one is to assign 'margin-right' to button.
To fix this I removed the "pull-right" and the spacing worked from bootstraps "modal-footer" class.
<div className= "modal-footer">
<Button bsStyle = "primary" formNoValidate={true} type="submit">Submit</Button>
<Button bsStyle = "default" onClick={this.resetForm} type="reset">Reset</Button>
</div>

Bootstrap <button> links?

Twitter Bootstrap uses button as links. How can I create an href or link this to something?
I am trying to swap these for a but, as expected, they get all messed up!
Twitter button :
<button class="btn btn-large btn-primary" type="button">Large button</button>
If you want to add a link then simply add a class to that a href :
<a href="#" class="btn btn-large btn-primary" >My Link</a>
it simple you can add class btn to link like this
<a href="#" class="btn btn-success" >ddd</a>

Resources