我遇到了一个问题,html没有被传送到popover。弹出窗口中没有包含一个表单,而是呈现为空。
这里是js。
$(document).on('mouseover', '.with-popover', function() {
var elem_id = $(this).attr('name')
$(this).popover({
trigger: 'click',
html: true,
placement: 'top',
container: 'body',
content: function(){
return $("#popover-div" + elem_id).html();
这里是HTML
<td id="td-name{{cleaning.id}}" class="text-md-center with-popover" name="{{cleaning.id}}"> {{ cleaning.name }}
<div id="popover-div{{cleaning.id}}" style="display: none">
<form method="post">
<label for="cleaning_name">Name: </label>
<input type="text" name="cleaning_name" value="{{ cleaning.name }}">
<button type="submit" class="btn btn-success btn-sm update-cleaning"> Update </button>
</form>
</div>
</td>
任何帮助将是感激的。谢谢你的帮助。
对于会遇到这个问题的人来说。你只需要添加 sanitize: false 到你的popover。如果您使用ajax调用从服务器接收数据,请使用
$(document).on('mouseover', '.with-popover', function() {
切换弹出式菜单。