ASP.net中的jQuery自动完成功能当以Ajax方式创建控件时,MVC不起作用

时间:2022-09-21 03:20:24

I am running an issue, could you help me out with your knowledge..?

我正在运行一个问题,你能用你的知识帮助我吗?

Basically, this autocomplete extension of jQuery depends onto the ready method of the jQueryLibrary. (I am not 100% sure what it does actually, but I can guess it checks wheather the DOM has been loaded, if loaded it does something as an regular "onload" event handler).

基本上,jQuery的这个自动完成扩展依赖于jQueryLibrary的ready方法。 (我不是100%确定它实际上做了什么,但我可以猜测它会检查DOM已经加载,如果加载它会做一些常规的“onload”事件处理程序)。

Now, I have an ASP.net MVC application where I am using Ajax to render a partial view (an ascx file) and that file contains the autocomplete textbox.

现在,我有一个ASP.net MVC应用程序,我使用Ajax渲染部分视图(ascx文件),该文件包含自动完成文本框。

As the DOM has been already loaded and I am now modified the DOM with the content of the ascx file in an Ajax fashion, my text boxes into the ascx are not doing anything autocompletion. What could be an alternate or workaround of this problem..? Even I am a bit curious why it's not working..?

由于DOM已经加载,我现在用Ajax方式修改了带有ascx文件内容的DOM,我在ascx中的文本框没有做任何自动完成。什么可能是这个问题的替代或解决方法..?即使我有点好奇为什么它不起作用..?

1 个解决方案

#1


you need to load the autocomplete function again as like you said the new items in the dom have come after the jquery already loaded. You can either put the jquery function in the ascx (simple way) or force the jquery to run on the DOM again which may cause unintended results.

你需要再次加载自动完成功能,就像你说已经加载了jquery之后dom中的新项目一样。您可以将jquery函数放入ascx(简单方式)或强制jquery再次在DOM上运行,这可能会导致意外结果。

#1


you need to load the autocomplete function again as like you said the new items in the dom have come after the jquery already loaded. You can either put the jquery function in the ascx (simple way) or force the jquery to run on the DOM again which may cause unintended results.

你需要再次加载自动完成功能,就像你说已经加载了jquery之后dom中的新项目一样。您可以将jquery函数放入ascx(简单方式)或强制jquery再次在DOM上运行,这可能会导致意外结果。