Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add a "Like" Button in Twitter's Bootstrap Popover?

I have a button which launches a popover when clicked (just like the live demo here: http://twitter.github.com/bootstrap/javascript.html#popovers)

Now I would like a simple like button in the content field of the popover. Is that possible? Currently, the popover does display only the link as text "http://test.com"

Currently:

<a href="#" id="example" rel="popover" data-content="http://test.com" data-original-title="Like"><img src="img/specialbutton.png"></a>
like image 413
Paranoia Avatar asked Oct 23 '12 08:10

Paranoia


People also ask

How do I customize Bootstrap popover?

To create a popover, you need to add the data-bs-toggle="popover" attribute to an element. Whereas, popover's title and its content that would display upon trigger or activation can be specified using the title and data-bs-content attribute respectively.

How do I use bootstrap popover?

To create a popover, add the data-toggle="popover" attribute to an element. Note: Popovers must be initialized with jQuery: select the specified element and call the popover() method.

Does bootstrap include popper?

js and minified bootstrap. bundle. min. js ) include Popper, but not jQuery.

How do you trigger a popover manually?

Default title value if title attribute isn't present. If a function is given, it will be called with its this reference set to the element that the popover is attached to. How popover is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space.


1 Answers

I am not completly sure what you mean with a like-button. In order to place a button with the anchortext "like" and a link to "http://test.com" on the popover :

1 Remove all data-xxx references from your <a>-tag

<a href="#" id="example" rel="popover"><img src="img/specialbutton.png"></a>

2 invoke the popover like this

$('#example').popover({
  placement: 'right',
  title: 'Like this website?',
  html: true,
  content: '<button class="btn"><a href="http://test.com">Like</a></button>'
});

You can place many types of HTML-tags in content, maybe you want a gruop of buttons to various social media? If you want to add a facebook-button you must follow the guidelines for this and insert the code generated from there in content

like image 127
davidkonrad Avatar answered Sep 23 '22 12:09

davidkonrad