0
我正在动态加载ASP.NET MVC 3视图。在视图内部,有一个需要“自动完成”的文本框。下面的代码:jQuery自动完成不在ASP.NET MVC视图内动态加载
@model CountryViewModel
@using (Html.BeginForm("Create", "Country", FormMethod.Post)) {
@Html.ValidationSummary(true)
<div class="field">
@Html.LabelFor(model => model.Name)
@Html.TextBoxFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="field">
@Html.LabelFor(model => model.Description)
@Html.TextBoxFor(model => model.Description)
</div>
<div class="field">
@Html.LabelFor(model => model.Latitude)
@Html.TextBoxFor(model => model.Latitude)
</div>
<div class="field">
@Html.LabelFor(model => model.Longitude)
@Html.TextBoxFor(model => model.Longitude)
</div>
@Html.HiddenFor(model => model.CultureId, new { id = "CultureId" })
}
<script type="text/javascript">
$(document).ready(function() {
$('#Name').autocomplete({
source: function(request, response) {
$.ajax({
url: '@(Url.Action("GetCountriesB", "Country"))',
data: "{ 'countryName': '" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function(data) { return data; },
success: function(data) {
response($.map(data.d, function(item) {
return {
value: item.Country
}
}))
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
},
minLength: 2,
focus: function(event, ui) {
$('#Name').val(ui.item.Country);
return false;
}
});
});
我加载此查看一个jQuery用户界面对话框内。当我使用Firebug进行调试时,“脚本”标签似乎未加载,因此自动完成功能无法使用。
任何想法为什么会有这种行为?
谢谢
我看不到任何'
我有同样的问题,结果证明z-index太低。它实际上工作,但没有显示。
来源
2016-08-04 10:18:31