Reputation: 528
I'm trying to use popover
but the problem is the close button is not working inside of data-content
, I already tried to put it in title
and it worked fine but I really need to put it in data-content
:)
thanks you all...
$(function () {
$('[data-toggle="popover"]').popover();
});
.btn {
margin:80px
}
body {
background: #f5f5f5
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<button class="btn btn-success btn-edit"
data-toggle="popover"
data-html='true' data-placement="bottom"
data-content='<button type="button" id="close" class="close" onclick="$(".btn-edit").popover("hide");">×</button>'>
CLICK ME
</button>
Upvotes: 1
Views: 1221
Reputation: 90277
HTML entities ("
) do not get parsed inside JavaScript expressions and that's what you have inside onlick
attribute. But you can use backtick instead of single quote. i.e:
<button data-content='<button onclick="$(`.btn-edit`).popover(`hide`);">...</button>'>
$(function () {
$('[data-toggle="popover"]').popover();
});
.btn {
margin:80px
}
body {
background: #f5f5f5
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<button class="btn btn-success btn-edit"
data-toggle="popover"
data-html='true' data-placement="bottom"
data-content='<button type="button" id="close" class="close" onclick="$(`.btn-edit`).popover(`hide`);">×</button>'>
CLICK ME
</button>
Upvotes: 1