这是绑定popover的JavaScript代码。当我选择下拉选项时,它会自动关闭,并且不会在下拉列表中选择任何元素。
$("[data-toggle=popoverGroupByEmp3]")
.popover({
datahtml: true,
html: true,
'title': 'Salary payble account code',
content: function() {
var iD = $(this).attr('data-Id');
return $(".jvAccountCode").html();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-sm-12 hidden jvAccountCode">
<div class="col-sm-12">
@Html.DropDownList("ddl_AccountCode", (List
<SelectListItem>)ViewBag.lstAccountCode, "Select account code", new { @class = "form-control selectpickerddl" })
</div>
<div class="popover-footer pull-right">
<button id="close-popover" data-toggle="clickover" onclick="$('[data-toggle=popoverGroupByEmp3]').popover('hide');" type="button" class="btn btn-default popover-cancel">
<i class="glyphicon glyphicon-remove"></i>
</button>
<button type="button" class="btn btn-primary popover-submit">
<i class="glyphicon glyphicon-ok"></i>
</button>
</div>
</div>
这是我在MVC中使用的HTML。