Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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
C#
 // GET: /TagNode/
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
HTML
<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.
Posted
Comments
Sergey Alexandrovich Kryukov 25-Jun-12 15:43pm    
Did you include jQuery UI, which is a separate library?
--SA

1 solution

First thing which comes to mind is that you simply did not include jQuery UI library. This is a library separate from jQuery and depending on it. Please see:
http://docs.jquery.com/UI[^].

To download it, please see:
http://docs.jquery.com/UI/Subversion[^].

Good luck,
—SA
 
Share this answer
 
v3
Comments
Member 8336910 25-Jun-12 16:17pm    
I can't believe that was it. I've been trying to find the problem for 2 days. Hahaha thanks so much!
Sergey Alexandrovich Kryukov 25-Jun-12 16:40pm    
You are very welcome.
Good luck, call again.
--SA
SoMad 25-Jun-12 17:10pm    
Good advice, +5.

Soren Madsen
Sergey Alexandrovich Kryukov 25-Jun-12 17:12pm    
Thank you, Soren.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900