我遇到了无法将HTML传输到弹出窗口的问题。弹出窗口没有包含其中的表单,而是变为空的。
这是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>
任何帮助将不胜感激。谢谢。
答案 0 :(得分:0)
针对将遇到此问题的任何人。您只需要在弹窗中添加 sanitize:false 。另外,如果您使用ajax调用从服务器接收数据,请使用
$(document).on('mouseover', '.with-popover', function() {
切换弹出窗口。