未捕获的TypeError:对象[object Object]没有方法'autocomplete'(可能不是冲突问题)

时间:2013-09-20 16:44:21

标签: javascript jquery autocomplete

我意识到这个帖子已经有很多朋友已经在这里和其他所有网站,但所有线程似乎以“你有冲突”结束。如果我确实有冲突,我没有看到它,如果它在那里,可能是由于Telerik及其RadGrid,RadToaster,RadYoyo等在页面上。但也可能是因为我错过了一些东西。如果我删除< head>中的jQuery包含,我会收到“$ is not defined”错误。

这是< head>内容,包括jQuery包含但不包括Telerik< link>标签。任何帮助,将不胜感激。我很难过。

带控件的HTML:

    <div id="search">
        <form method="get">
            <input name="ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$q" type="text" id="ContentPlaceHolder1_ContentPlaceHolder1_q" size="35" placeholder="Search..." />
        </form>
    </div>

部首:

<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-40617410-1']);
    _gaq.push(['_trackPageview']);

    (function () {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<link rel="stylesheet" href="../Content/smoothness/jquery-ui-1.10.0.custom.min.css" /><link href="../Content/Site.css" rel="stylesheet" type="text/css" /><link href="Parts.css" rel="stylesheet" type="text/css" />


<script language="javascript" type="text/javascript" src="../Scripts/LiveHelp.js"></script>

<script type="text/javascript" src="/Scripts/gridHelpers.js"></script>




    <script type="text/javascript">
        // needs to be present for clearFilter()
        var radGrid;

        $(document).ready(function () {
            $('#ContentPlaceHolder1_ContentPlaceHolder1_q').bind('keypress', function (e) {
                var code = (e.keyCode ? e.keyCode : e.which);
                if (code == 13)
                    DoSearch($('#ContentPlaceHolder1_ContentPlaceHolder1_q').val());
            });

            //$('#orderHistoryButton').bind('click', function () {
            //    DoOrderHistory();
            //});

            $('#ContentPlaceHolder1_ContentPlaceHolder1_favoritesButton').bind('click', function () {
                DoFavorites();
            });

            //$('#mostPopularButton').bind('click', function () {
            //    DoMostPopular();
            //});

            $("#ContentPlaceHolder1_ContentPlaceHolder1_CategoryFilter").change(function () {
                DoCategoryFilter($(this).val());
                //DoCategoryFilter(cat_ddl.val());
            });

            $('#ContentPlaceHolder1_ContentPlaceHolder1_q').autocomplete({ source: ['Lid'] });
            radGrid = $find("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_RadGrid1");
        });

        function DoSearch(searchText) {
            $("#ContentPlaceHolder1_ContentPlaceHolder1_CategoryFilter").val('');
            $find("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_m_AjaxManager").ajaxRequest("Search" + "|" + searchText);
        }

        //function DoOrderHistory() {
        //    $('#ContentPlaceHolder1_ContentPlaceHolder1_q').val('');
        //    $find("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_m_AjaxManager").ajaxRequest("OrderHistory");
        //}

        function DoFavorites() {
            $('#ContentPlaceHolder1_ContentPlaceHolder1_q').val('');
            $find("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_m_AjaxManager").ajaxRequest("Favorites");
        }

        //function DoMostPopular() {
        //    $('#ContentPlaceHolder1_ContentPlaceHolder1_q').val('');
        //    $find("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_m_AjaxManager").ajaxRequest("MostPopular");
        //}

        function DoCategoryFilter(id) {
            $('#ContentPlaceHolder1_ContentPlaceHolder1_q').val('');
            $find("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_m_AjaxManager").ajaxRequest("Filter|" + id);
        }

        function AddToCart(partId) {
            var quantity = $('#qty_' + partId).val();
            $find("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_m_AjaxManager").ajaxRequest("AddToCart" + "|" + partId + "|" + quantity);
            var currentQuantity = parseInt($find("ContentPlaceHolder1_ContentPlaceHolder1_m_CartItemCountLabel").innerHTML);
            if (!isNaN(currentQuantity)) {
                currentQuantity += quantity;
                $find("ContentPlaceHolder1_ContentPlaceHolder1_m_CartItemCountLabel").innerHTML = currentQuantity;
            }
        }

        function refreshGrid(arg) {
            if (!arg) {
                $find("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_m_AjaxManager").ajaxRequest("Rebind");
            }
            else {
                $find("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_m_AjaxManager").ajaxRequest("RebindAndNavigate");
            }
        }

        function ShowDetailView(id) {
            window.radopen("DetailView.aspx?id=" + id, "DetailViewWindow");
            return false;
        }

        function ImagePreview(id) {

        }


    </script>


<style>body { background: transparent url('/images/background4.jpg') no-repeat top center; }</style>

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

        $("td.menu > li").css("color", "red");
        $("li ul li").css("color", "blue")
        $("li ul li").hide();
        $("ul.menu li").hover(

        function () {
            $("ul li", this).show();
        }, function () {
            $("ul li", this).hide();
        }

        );

    });
</script>
<style type="text/css" media="screen">
    body {
        background-size: 100% auto;
    }

    .mymenu
    {    
        margin: 0;
        padding: 0;
    }

    .mymenu li
    {    
        width: 100px;
        margin: 0;
        padding: 0px;
        list-style: none;
        float: left;
    }

    .mymenu li a
    {    
        display: block;
        margin: 0 1px 0 0;
        padding: 4px 0px;
        width: 100px;
        /*background: #bbbaaa;*/
        color: #ffffff;
        text-align: center;
    }

    .mymenu ul a:hover
    {    
        background: #2f2f2f
    }

    .mymenu ul
    {    
        position: absolute;
        visibility: hidden;
        margin: 0 1px 0 0;
        padding: 0;
        /*background: #eeebdd;*/
        /*border: 1px solid #ffffff*/

    }

    .mymenu ul a
    {    
        position: relative;
        display: block;
        margin: 0 1px 0 -30px;
        padding: 5px 10px;
        width: 140px;
        text-align: left;
        background: #000000;
        color: #ffffff;
    }    
</style>
<script type="text/javascript">
    //variables' declaration
    var timer     = 0;
    var item      = 0;

    //function for opening of submenu elements
    function openelement(num)
    {    

        //checks whether there is an open submenu and makes it invisible 
        if(item) item.style.visibility = 'hidden';

        //shows the chosen submenu element
        item = document.getElementById(num);
        item.style.visibility = 'visible';
    }

    // function for closing of submenu elements
    function closeelement()
    {
        //closes the open submenu elements and loads the timer with 500ms
        timer = window.setTimeout("if(item) item.style.visibility = 'hidden';",500);
    }

    //function for keeping the submenu loaded after the end of the 500 ms timer
    function keepsubmenu()
    {
        window.clearTimeout(timer);
    }
    //hides the visualized menu after clicking outside of its area and expiring of the loaded timer
    document.onclick = closeelement; 

</script>

1 个答案:

答案 0 :(得分:1)

当然这是一场冲突! 代码在我错过的RadScriptManager中包含了Telerik jQuery。在接管代码时我应该更加敏锐。