Question : why can't autocomplete after div is loaded via ajax when autocomplete is in the div box

why can't autocomplete after div is loaded via ajax when autocomplete is in the div box?

it doeasn't work even there is OnComplete="setAutoComplete"
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
function setAutoComplete() {

    var columns = ["GALACXY_ID", "CONTACT_POINT", "LOCATION", "CONFIRMED_LOC", "ASSOCIATED_TO", "OLD_ASSET_TAG", "TX_ITEMS_ASSET_TAG"];

    for (i = 0; i < columns.length; i++) {
        $('#' + columns[i]).focus(
                        function () {

                            var controlitem;
                            if (ArrayIndexOf(columns, $(this).attr("ID")) > -1)
                                controlitem = $(this);
                            else
                                controlitem = $('#' + columns[i]);


                            if (controlitem.attr("ACDONE") == "Y") {
                            }
                            else {

                                controlitem.attr("ACDONE", "Y");
                                //$('#LOCATION').unautocomplete();
                                controlitem.autocomplete('/ASSET/Lookup', { //<%= Url.Action("Lookup", "ASSET") %>
                                    dataType: 'json',
                                    parse: function (data) {
                                        var rows = new Array();
                                        if (data != null) {
                                            for (var i = 0; i < data.length; i++) {
                                                rows[i] = { data: data[i], value: data[i].ID, result: data[i].ID };
                                            }
                                        }
                                        return rows;
                                    },
                                    formatItem: function (row, i, n) {
                                        return row.ID + ' - ' + row.TEXT;
                                    },
                                    width: 500,
                                    height: 500,
                                    //mustMatch: true, ////mustMatch: true,
                                    extraParams: {
                                        Field: function () { return controlitem.attr("ID"); },
                                        //OldValue: function () { return $("#LOCATION").attr("OldValue"); }
                                        OldValue: function () { return controlitem.val(); },
                                        CHECK_IN_OUT_LOCATION: function () { return $("#CHECK_IN_OUT_LOCATION").val(); }
                                    }

                                })
                            }
                        }
                    );
    }

Answer : why can't autocomplete after div is loaded via ajax when autocomplete is in the div box

I believe the best option is to "sanitize" the xml you are trying to save. Have a look on the snippet below - it works for your case. I xml text from a file.

See also for additional ideas"

http://prettycode.org/2009/05/07/hexadecimal-value-0x-is-an-invalid-character/
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
        private void button1_Click(object sender, EventArgs e)
        {

            try
            {
                char ch_03 = '\x03';

                StringBuilder sb = new StringBuilder();

                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (StreamReader sr = new StreamReader("index.txt"))
                {
                    String line;
                    // Read and display lines from the file until the end of 
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        sb.AppendLine(line.Replace(ch_03, ' '));
                    }
                }
             
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(sb.ToString());

                XmlDeclaration dec = doc.FirstChild as XmlDeclaration;
                if (dec != null)
                {
                    dec.Encoding = "UTF-8";
                }
                doc.Save("test.rss");
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }
        }
Random Solutions  
 
programming4us programming4us