![](/img/trans.png)
[英]Jquery UI Autocomplete widget conflicts with jquery.menu widget
[英]jquery ui autocomplete conflicts with foundation install with nuget
我使用nuget來安裝基礎和jquery ui(將安裝jquery)。 我有一個正在工作的MVC 5網站。
在添加基礎之前,jQuery自動完成控制工作正常。 但是,安裝控件后仍然可以使用,但是您在其中進行選擇的下拉菜單消失了。
我遇到了與Zurb Foundation一起使用的此解決方案樣式自動完成功能,這是我認為的同一個人... http://ezra.keddell.co.nz/implementing-jquery-autocomplete-in-zurb-foundation-4/ 。 它們是我在搜索中遇到的唯一解決方案。 但是我認為這對我不起作用,因為從我可以看出,當您通過nuget安裝Foundation時,jquery並沒有它。 因此,他要使用以下代碼修改的文件無效,我也不知道哪些文件是正確的文件。 我也不明白為什么這樣有意義。
<script>
document.write('<script src=' +
('__proto__' in {} ? 'js/vendor/zepto' : 'js/vendor/jquery') +
'.js><\/script>')
</script>
我想我正在尋找一種方法來使jquery ui和foundation一起工作,以實現自動完成控件。 是否可以告知Foundation停止工作一段時間或使其不影響自動完成控件的樣式。
我擁有的確切代碼是...
Layout.cshtml
<head>
<meta charset="utf-8" />
@Styles.Render("~/Content/foundation/css")
@Styles.Render("~/Content/site.css")
@RenderSection("head", required: false)
@Scripts.Render("~/bundles/modernizr")
</head>
<div id="mainWrap" class="row">
<div class="Columns small-12 small-centered">
@RenderBody()
</div>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/foundation")
<script>
$(document).foundation();
</script>
@*Use the Scripts section to define page specific scripts*@
@RenderSection("scripts", required: false)
index.cshtml
<script>
$(document).ready(function () {
$("#Name").autocomplete({
// how does the request get a value?
source: function GetRemoteData(request, response) {
var name = $("#Name").val();
$.ajax({
type: "GET",
url: "/api/attendees/" + name,
cache: false,
data: request,
dataType: "json",
success: function (json) {
// call autocomplete callback method with
response($.map(json, function (name, val) {
return {
label: name,
value: val
};
}));
},
error: function (XMLHttpRequest, textStatus, e) {
alert("error - " + textStatus);
console.log("error", textStatus, errorThrown);
}
}); // end $.ajax
},
minLength: 2,
select: function (event, ui) {
alert("you have selected " + ui.item.label + "Id: " + ui.item.value);
$("#Name").val(ui.item.label);
return false;
}
}); // end autocomplete
// supposedly to help foundation and jquery ui work together.
$('.ui-autocomplete').addClass('f-dropdown');
}); // end ready
</script>
@using (Html.BeginForm("Submit", "Home")) {
@*<label>Your Name:</label> <input type="text" id="Name" name="Name" value="@Html.Raw(Model.Firstname) @Html.Raw(Model.LastName)" /> <br />*@
<label>Your Name:</label> <input type="text" id="Name" name="Name" value="" /> <br />
@Html.LabelFor( x=> x.Attending ) @Html.CheckBoxFor( x=> x.Attending ) @*<label>Attending:</label>*@ @*<input type="checkbox" id="Attending" name="Attending" />*@ <br />
@Html.LabelFor( x => x.Windermere ) @Html.CheckBoxFor( x => x.Windermere ) @*<label>Staying at the Windermere Manor:</label>*@ @*<input type="radio" id="radioYes" /> <input type="radio" id="radioNo" /> <input type="radio" id="radioMaybe" />*@ <br />
@Html.TextAreaFor( x => x.Notes )<label>Notes:</label> @*<textarea id="AttendanceNotes" name="AttendanceNotes"> </textarea>*@ <br />
<button id="Submit" name="Sumbit">Submit</button>
}
確實很不幸,但這並不是Foundation和jquery ui之間的沖突。如果您仔細查看上方的內容,您會注意到我沒有包括jquery UI css樣式表。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.