对象不支持属性或方法'autocomplete' [英] Object doesn't support property or method 'autocomplete'

查看:105
本文介绍了对象不支持属性或方法'autocomplete'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题,我经历了很多论坛,并遵循很多方法来实现它。



通过Nuget Package Manager我得到Jquery UI Combined添加引用我的项目。



脚本文件被添加到Script文件夹以及Content文件夹中的css文件。



我只是拖着&放下并放在.cshtml文件上



Atfirst,Intellisense没有显示自动完成属性。但现在它显示自动完成属性。我仍然得到这个错误。



我想的是我添加了很多脚本文件。

我有jquery.ui.js,jquery.ui。 min.js,已经在Mvc项目中有一个Jquery 1.10.2.js,jquery 1.10.2.min.js



现在,我在这里显示我的代码通过它让我知道什么是错的



先谢谢。



什么我试过了:



in .cshtml



@Model IEnumerable< modelclass.dhoniregistry> ;





< link href =〜/ Content / jquery-ui.min.css =stylesheet/> ;

< link href =〜/ Content / jquery-ui.structure.min.css =stylesheet/>

< link href = 〜/ Content / jquery-ui.theme.min.css =stylesheet/>

< script src =〜/ Scripts / external / jquery / jquery.js> ;< / script>

< script src =〜/ Scripts / jquery-ui.min.js>< / script>

< script SRC =http://code.jquery.com/ui /1.10.3/jquery-ui.js\"></script>



< script type =text / javascript>

$(function()

{

$(#txtSearch)。autocomplete({source:'@ Url.Action(ASDhoniName)' });

});



< / script>



@using(@ Html.BeginForm())

{

Dhoni名称

@ Html.TextBox( SearchTerm,null,new {id =txtSearch})

< input type =submitvalue =Search/>

}





public JsonResult ASDhoniName(字符串术语)

{

DhoniRegistryBusinessSer dhoniBisSer = new DhoniRegistryBusinessSer();



List< string> dhoniReg;



dhoniReg = dhoniBisSer.ListDhoniRegistry()。其中​​(x => x.DhoniName.StartsWith(term))

。选择(y => y.DhoniName).ToList();



返回Json(dhoniReg,JsonRequestBehavior.AllowGet);

}

I have this issue I go through lot of forums and follows lot of Ways to Implement it.

Through Nuget Package Manager I get Jquery UI Combined Add reference to My Project.

Scripts files Were added to the Script folder as well as css files in the Content folder.

I just drag & drop and put it on .cshtml file

Atfirst, Intellisense didn't show AutoComplete Property. But Now It Shows the AutoComplete Property. Still I get this Error on.

What I am thinking is by Mistakenly lot of Script files I added.
I have jquery.ui.js,jquery.ui.min.js, and already In Mvc project there's an Jquery 1.10.2.js,jquery 1.10.2.min.js

Now,I Show My Code here please go through it and let me know what went Wrong

Thanks in Advance.

What I have tried:

In .cshtml

@Model IEnumerable<modelclass.dhoniregistry>


<link href="~/Content/jquery-ui.min.css" rel="stylesheet" />
<link href="~/Content/jquery-ui.structure.min.css" rel="stylesheet" />
<link href="~/Content/jquery-ui.theme.min.css" rel="stylesheet" />
<script src="~/Scripts/external/jquery/jquery.js"></script>
<script src="~/Scripts/jquery-ui.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

<script type="text/javascript">
$(function ()
{
$("#txtSearch").autocomplete({ source: '@Url.Action("ASDhoniName")' });
});

</script>

@using (@Html.BeginForm())
{
Dhoni Name
@Html.TextBox("SearchTerm", null, new { id = "txtSearch" })
<input type="submit" value="Search" />
}

In Controller

public JsonResult ASDhoniName(string term)
{
DhoniRegistryBusinessSer dhoniBisSer = new DhoniRegistryBusinessSer();

List<string> dhoniReg;

dhoniReg = dhoniBisSer.ListDhoniRegistry().Where(x => x.DhoniName.StartsWith(term))
.Select(y => y.DhoniName).ToList();

return Json(dhoniReg,JsonRequestBehavior.AllowGet);
}

推荐答案

(function()

{
(function ()
{


(#txtSearch ).autocomplete({source:'@ Url.Action(ASDhoniName)'});

});



< / script>



@using(@ Html.BeginForm())

{

Dhoni姓名

@ Html.TextBox(SearchTerm,null,new {id =txtSearch})

< input type =submitvalue =搜索/>

}



控制器



public JsonResult ASDhoniName(字符串术语)

{

Dhon iRegistryBusinessSer dhoniBisSer = new DhoniRegistryBusinessSer();



List< string> dhoniReg;



dhoniReg = dhoniBisSer.ListDhoniRegistry()。其中​​(x => x.DhoniName.StartsWith(term))

。选择(y => y.DhoniName).ToList();



返回Json(dhoniReg,JsonRequestBehavior.AllowGet);

}
("#txtSearch").autocomplete({ source: '@Url.Action("ASDhoniName")' });
});

</script>

@using (@Html.BeginForm())
{
Dhoni Name
@Html.TextBox("SearchTerm", null, new { id = "txtSearch" })
<input type="submit" value="Search" />
}

In Controller

public JsonResult ASDhoniName(string term)
{
DhoniRegistryBusinessSer dhoniBisSer = new DhoniRegistryBusinessSer();

List<string> dhoniReg;

dhoniReg = dhoniBisSer.ListDhoniRegistry().Where(x => x.DhoniName.StartsWith(term))
.Select(y => y.DhoniName).ToList();

return Json(dhoniReg,JsonRequestBehavior.AllowGet);
}


你有两个对jquery UI的引用,所以试着删除这个。



You have two references to jquery UI so try deleting this one

<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>





确保你只有一个对jQuery的引用。



Ensure you only have one reference to jQuery also.


这篇关于对象不支持属性或方法'autocomplete'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆