jQuery选择的项目在回发时丢失 [英] Jquery selected item lost on Postback

查看:42
本文介绍了jQuery选择的项目在回发时丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我已经使用JQuery自动完成器在文本框内显示数据库的值列表.

它工作正常,直到我使用了该文本框的TEXTCHANGED事件.现在,我需要使用TEXTCHANGED事件来更新用户更改的值.

当我键入"a"时,它将向我显示以"a"开头的单词列表,例如"asp.net,asp ..."

问题是,如果用户从鼠标"中选择值,它将失去焦点,并引发TEXTCHANGED事件.但是,当我按TAB或ENTER键时,它的效果很好.

因此,我想到了使用隐藏字段"并保存文本框的值并检索它.
经过大量研究后,我发现了该值,该值已分配给"autocomplete.js"中的TEXTBOX.
我确实做了一个"alert()"来检查它

我是JQuery的新手,请帮帮我.

我的代码在下面...




I have using an JQuery Autocompleter to show the list of values from database inside an textbox.

Its works fine, untill i used TEXTCHANGED event of that textbox. Now i need to use TEXTCHANGED event to update user changed values.

While i type "a" it will shows me list of words starts with "a" like "asp.net, asp..."

Problem is, if user select the values from "mouse" it will lost focus and TEXTCHANGED event raised. But while i hit TAB or ENTER key its works fine.

Hence i thought of using "HIDDEN FIELD" and save the value of textbox and retrieve it.
After big research i found the value, which was assigned to TEXTBOX inside "autocomplete.js"
I did check it out by made an "alert()"

I''m newer to JQuery, Please help me out.

My code is below...

<link href="../../StyleSheets/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
<script src="../../StyleSheets/SearchScript/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="../../StyleSheets/SearchScript/jquery.autocomplete.js" type="text/javascript"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $("#<%=txt_custname.ClientID%>").autocomplete('CustomerHandler.ashx');
        var data = $('#txt_custname.ClientID').value;
        $('#hidden').val(data);
        if(data != "")
        {
        var hid = $('#hidden').value;
        alert(hid);
        }
     });
</script>


<asp:HiddenField ID="hidden" runat="server"/>

推荐答案

(document).ready(function(){
(document).ready(function() {


(#%> ").autocomplete('CustomerHandler.ashx'); var data =
("#<%=txt_custname.ClientID%>").autocomplete('CustomerHandler.ashx'); var data =


('#txt_custname.ClientID').value;
('#txt_custname.ClientID').value;


这篇关于jQuery选择的项目在回发时丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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