Subby
Subby

Reputation: 5480

ASP.NET MVC 3 AutoComplete

I pasted the sample code from here in my .cshtml file just to see if it works with hard-coded data.

For some ready, the autocomplete doesn't work when I type.

The following is the code:

<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>
<div class="demo">

<div class="ui-widget">
    <label for="tags">Tags: </label>
    <input id="tags">
</div>

</div><!-- End demo -->

There are other controls and tables etc after this of course.

Can anyone spot where I may be going incredibly wrong?

Upvotes: 0

Views: 177

Answers (2)

Big Daddy
Big Daddy

Reputation: 5224

Try adding this to your .cshtml. It's what I use to get the intellisense working.

@if (false) { <script src="/Scripts/jquery-1.7.2-vsdoc.js" type="text/javascript"></script>  }

Upvotes: 1

webdeveloper
webdeveloper

Reputation: 17288

This code works. You need to include:

  • jquery js
  • jquery-ui css
  • jquery-ui js

Your code example (without css): jsfiddle.net/cZYuA/

Upvotes: 0

Related Questions