我用nuget安裝基礎和jquery ui(安裝jquery)。我有一個我正在開發的MVC 5網站。jquery ui自動完成衝突與基金會安裝與nuget
在我添加基礎之前,jquery自動完成控件工作正常。但是,安裝完成後,控件仍然有效,但是您選擇的下拉菜單消失了。
我跑過這個解決方案Style autocomplete with Zurb Foundation,這是來自同一個傢伙,我認爲... http://ezra.keddell.co.nz/implementing-jquery-autocomplete-in-zurb-foundation-4/。他們是我在搜索中遇到的唯一解決方案。但是我不認爲它適用於我,因爲從我可以告訴當你通過nuget安裝基礎它不會帶有jQuery。所以他想用下面的代碼修改的文件是無效的,我不知道哪些文件是正確的。我也不明白爲什麼這是有道理的。
<script>
document.write('<script src=' +
('__proto__' in {} ? 'js/vendor/zepto' : 'js/vendor/jquery') +
'.js><\/script>')
</script>
我想我正在尋找一種方式來獲得jQuery用戶界面和基礎,爲autocomplet控制的目的共同努力。是否有可能告訴基金會停止工作一段時間,或讓它不影響自動完成控件的樣式。
確切的代碼我已經是...
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>
}
爲什麼有人投下這個問題,甚至沒有告訴海報爲什麼? – 2014-11-21 10:08:16