[英]jquery autocomplete not working in VS2012 but works fine in VS2010
I was trying to use autocomplete and it is not working in VS2012. 我试图使用自动完成功能,但在VS2012中不起作用。 So, i took a sample from jQuery( http://jqueryui.com/autocomplete/#default ) and pasted the same in VS2012 and VS2010.
因此,我从jQuery( http://jqueryui.com/autocomplete/#default )获取了一个示例,并将其粘贴到了VS2012和VS2010中。 It works fine in 2010 but throws exception in 2012.
它在2010年运作良好,但在2012年抛出异常。
Any idea why this is happening? 知道为什么会这样吗?
To avoid any case of plugins or scripts mismatch, I used the cdn references as given by jquery site. 为了避免插件或脚本不匹配的情况,我使用了jquery网站提供的cdn引用。
Here is the source code I have used. 这是我使用过的源代码。 This is the only content and nothing else has been added in VS2012 and VS2010
这是唯一的内容,在VS2012和VS2010中没有添加任何其他内容
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags" />
</div>
</body>
</html>
EDIT: I have observed that in VS2012 it is attaching the default layout if none mentioned. 编辑:我观察到,在VS2012中,如果没有提及,它将附加默认布局。 Again, if we remove the "@RenderSection("scripts", false);"
同样,如果我们删除“ @RenderSection(“ scripts”,false);” in the layout.cshtml file, things will start working.
在layout.cshtml文件中,一切将开始工作。
Anyone, knows why is this? 有人知道这是为什么吗?
I got this. 我懂了。
Only change I did was to move the following piece of code in _Layout.cshtml from bottom to the head section. 我所做的唯一更改是将_Layout.cshtml中的以下代码从底部移至头部。
"@Scripts.Render("~/bundles/jquery")" “ @ Scripts.Render(”〜/ bundles / jquery“)”
:) Happy now. :) 现在开心。 Wasted almost a day on this.
浪费了将近一天的时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.