jQuery自动完成在AutoPostBack上丢失文本
I have a jQuery Autocomplete field on an ASP.Net Webform and everything has been working great until now. I also have a DropDownList that I have a need to fire onSelectedIndexChanged with AutoPostBack.
我在ASP.Net Webform上有一个jQuery Autocomplete字段,到目前为止一切都运行良好。我还有一个DropDownList,我需要使用AutoPostBack触发onSelectedIndexChanged。
When I changed my code to do the AutoPostBack, the text field that has the jQuery AutoComplete on it comes back blank. However, if I look at the source of the page, the text is in the text field. If I now post the form, the page will send back a blank field. My Google-Fu is weak on this one, as I could not come up with any workaround for it.
当我更改我的代码以执行AutoPostBack时,其上包含jQuery AutoComplete的文本字段将返回空白。但是,如果我查看页面的来源,则文本位于文本字段中。如果我现在发布表单,页面将发回一个空白字段。我的Google-Fu在这方面很弱,因为我无法提出任何解决方法。
Has anyone had any issues like this with the Autocomplete field getting blanked out on an AutoPostBack, and how did you get around it?
有没有人在AutoPostBack上自动填充字段被删除时出现这样的问题,你是如何解决这个问题的?
I can post code if it's really necessary, but I'd need to sanitize a lot of it before I could due to company policy.
如果确实有必要,我可以发布代码,但是由于公司政策的原因,我需要先对其进行清理。
2 个解决方案
#1
How is the autocomplete field being initialized? Is it being set to empty string either on page load from server or by the autocomplete jQuery plugin on document.ready?
如何初始化自动完成字段?是从服务器页面加载还是通过document.ready上的自动完成jQuery插件设置为空字符串?
If the source code for the plug-in is setting the textbox to empty string on document.ready then try the following:
如果插件的源代码将文本框设置为document.ready上的空字符串,请尝试以下操作:
// Store current textbox value in a var
var temp = $('#mytextbox').val();
// Initialize the autocomplete plugin (winging it on the syntax)
$('#mytextbox').autocomplete();
// Reset the value of the textbox.
$('#mytextbox').val(temp);
更多相关文章
- 如何在MVC4中使用type= " url "而不用jQuery将字段验证为url ?
- js限制文本框只能输入数字方法
- html中文本域选中后会出现蓝边框
- 使用表单字段值定制CSS属性。
- 使用换行符将textarea的文本复制到div中
- 9.1.4 前端 - HTML body标签 - 标题,段落,分割线,换行,特殊符号,列
- 更改所选文本的背景颜色,HTML JQUERY
- 在PHP中获取幕布元素ID的文本[重复]
- Server.Htmlencode用于文本域显示带的html代码