asdasda
asdasda

Reputation: 21

Popover Bootstrap - How to make it cleaner

I am trying to figure out different ways of building a popover without having to declare all of it's attributes in the tag. Is it possible to group it in a class, or declare it within .popover()?

For example, is it possible to change

<a href="#" id="example" class="btn btn-primary" rel="popover"
data-content="This is the body of Popover"
data-original-title="Creativity Tuts">pop
</a>

$(function () {
    $('#example').popover();
});

to something cleaner like this

<a href="#" id="cleaner" class="btn btn-primary">pop2</a>

$(function () {
    $('cleaner').popover({
        //where I would rather declare rel="popover", 
        //data-content="This is the body of Popover" and so on.
    });
});

Here's my jsfiddle.

Thank you in advance.

Upvotes: 0

Views: 45

Answers (3)

Molly Harper
Molly Harper

Reputation: 2453

Sure:

$(function () {
  $('#cleaner').attr({
    'rel': 'popover',
    'data-content': 'This is the body of Popover',
    'data-original-title': 'Creativity Tuts'
  });
  $('#cleaner').popover();
});

Upvotes: 1

zalex
zalex

Reputation: 799

I think you have to pay attantion to docs

Upvotes: 0

Joint
Joint

Reputation: 1218

Yes, it is possible, here you are:

$(function () {
    $('#cleaner').popover({
        content : "This is the body of popover",
        title : "Creativity Tuts",
    });
});

Upvotes: 2

Related Questions