Hi I am needing help to figure out what am I doing wrong. I am new to MVC 4 web application template. I am trying to get a simple autocomplete jquery to work. The following steps is the things I have done so far.
1. I created a new application using MVC 4 Intranet Web Application under Razor viewing engine.
2. Added new item in Model folder
3. The new item is LINQ to SQL
4. Server Explorer, went to my database and dragged and dropped my table I want to use.
5. Renamed it TagNodeDatabase, then saved
6. I added in a TagNodeController in the controller folder
7. In the TagNodeControlller I added in the MYPROJECTNAMESPACE.Models and
TagNodeDatabaseDataContext tn = new TagNodeDatabaseDataContext();
public ActionResult Search(string searchterm)
{
string searchResult = string.Empty;
var tags = (from t in tn.TagNodeDatabases
where t.TAG_NAME.Contains(searchterm)
select t).Take(10);
foreach(TagNodeDatabase tag in tags){
searchResult += string.Format("{0}|\r\n",tag);
}
return Content(searchResult);
}
8. I go to Index.cshtml and took out the the whole entire < ol > tag in the default layout
9. I added at the top
<link href="../../Content/themes/base/jquery.ui.autocomplete.css" rel="stylesheet"
type="text/css" />
<script src="../../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.ui.core.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.ui.autocomplete.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#tagnode").autocomplete({
source: '@Url.Action("Search","TagNode")'
});
});
</script>
<h2>FMCS Histroy Tool</h2>
@Html.TextBox("tagnode")
Then when I test it in IE. I get debug errors in the autocomplete script that says $.widget( "ui.autocomplete",
Object doesn't support this property or method
and
$("#tagnode").autocomplete({
source: '/TagNode/Search'
});
is
Object doesn't support this property or method
Please help me. I need help getting jquery stuff working then I can blast off and do my thing.