php - Attach JQuery Autocomplete to a text field which is loaded by Ajax call -


i have simple web application in have created wizard, each wizard page contains different form fields populated database, user presses next page data retrieved server using ajax call. here code of page retrieved server against ajax call. making simple understand..

function printadalertwizardstep($step)     {             switch($step)             {                 case 1: //step of wizard, first step                     print "welcome alert wizard,...";                     break;                 case 2: //second step of wizard contains text field want attach autocomplete list.                 ?> <table>         <tr>         <td>keywords</td>         <td><!-- text field want attach autocomplete -->         <input id="nalertkw" name="nalertkw" size="10" type="text">         </td>     </tr> </table>              <?php             break;             }         }     } 

and java script code attaching autocomplete keywords text field is

//script executed when page ready scripting $(document).ready(function() { var availabletags = [             "actionscript",             "applescript",             "asp",             "basic",             "c",             "c++",             "clojure",             "cobol",             "coldfusion",             "erlang",             "fortran",             "groovy",             "haskell",             "java",             "javascript",             "lisp",             "perl",             "php",             "python",             "ruby",             "scala",             "scheme"         ];         $( "#nalertkw" ).autocomplete({             source: availabletags         }); }); 

now problem form loaded after user presses next , $(document).ready() function has fired when #nalertkw text field doesn't exists. autocomplete not working. using jquery-ui autocomplete, how can attach autocomplete textfield loaded through ajax call?

edit: have tested setup on simple page (without ajax call) textfield , attaching autocomplete text field same way. works absolutely fine. confirms autocomplete setup correct, don't works when attached textfield retrieved through ajax call.

try hooking event in ajax call's :success handler, this,

$.ajax({                     url: "page.aspx/fetchemaillist",                     data: "{ 'mail': '" + request.term + "' }",                     datatype: "json",                     type: "post",                     contenttype: "application/json; charset=utf-8",                     datafilter: function (data) { return data; },                     success: function (data) {                                   $( "#nalertkw" ).autocomplete({                                     source: availabletags                               });                              }                         }))                     }        }); 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -