views:

55

answers:

2

In the following code I get an error that says autocomplete function Object is not a property or method

Here is the code:

<title><%= ViewData["pagetitle"] + " | " + config.Sitename.ToString() %></title>
    <script src="../../Scripts/jqueryui/jquery-ui-1.8.1.custom/development-bundle/ui/minified/jquery.ui.core.min.js"
        type="text/javascript"></script>
    <script src="../../Scripts/jqueryui/jquery-ui-1.8.1.custom/development-bundle/ui/minified/jquery.ui.core.min.js"
        type="text/javascript"></script>

    <script src="../../Scripts/jqueryui/jquery-ui-1.8.1.custom/development-bundle/ui/jquery.ui.widget.js"
        type="text/javascript"></script>

    <script src="../../Scripts/jqueryui/jquery-ui-1.8.1.custom/development-bundle/ui/jquery.ui.position.js"
        type="text/javascript"></script>

    <script src="../../Scripts/jqueryui/jquery-ui-1.8.1.custom/development-bundle/ui/jquery.ui.autocomplete.js"
        type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="/Scripts/main.js"></script>

    <script language="javascript" type="text/javascript">
        $(document).ready(function () {

            Categories();

            $('#tags1').autocomplete({ //error here
                url: '/Tag/TagAutoComplete',
                width: 320,
                max: 4,
                delay: 30,
                cacheLength: 1,
                scroll: false,
                highlight: false
            });

        });

    </script>
+1  A: 

why are you having two of this jquery.ui.core.min.js ?

and I see that you did not include jQuery libray... did you?

Reigel
OK..i took the extra one off and it still says the same thing
Luke101
you did not include jQuery.js, did you? http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js
Reigel
yes i sure did but it was added twicw. once in my local page and once in my master page. i guess made autocomplete fail
Luke101
+1  A: 

That's probably because the script are not found in the indicated location. I would recommend you using helpers for this. For example instead of writing:

<script src="../../Scripts/jqueryui/jquery-ui-1.8.1.custom/development-bundle/ui/minified/jquery.ui.core.min.js"
        type="text/javascript"></script>

always write:

<script src="<%= Url.Content("~/scripts/jqueryui/jquery-ui-1.8.1.custom/development-bundle/ui/minified/jquery.ui.core.min.js") %>"
        type="text/javascript"></script>

Make sure with FireBug that all the required scripts are properly loaded and that you don't have any javascript errors.

Darin Dimitrov
OMG..Thank you for telling me to check firebug..Actually I the jquery file and my javascript file was called in my master page and the local page, which made jquery error out. I found out by checking what was loaded in firebug. If I would have never checked that - I would have been stuck for days. Thanks again
Luke101