sanjay
sanjay

Reputation: 1

autocomplete does not work in dynamically loaded inner div of parent page?

autocomplete does not work in dynamically loaded inner div of parent page? i have a button in parent page,when i click that then another html is loaded in a empty div of parent page but that loaded another page is having auotcomplete drop down but that autocomplete does not work in that loaded form. My code is : another.html

<script type="text/javascript" src="jquery.js"></script>
<script type='text/javascript' src='jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script type="text/javascript">
$("#course").autocomplete("includes/addcandidate/get_course_list.php", {
width: 260,
matchContains: true,
selectFirst: false
    });
});
</script>
<td align="left"></td>

Parent.html

<input type="button" class="button small green" value="getCourseList" onclick="getCourseList();">
<div id = "getCourseList_innerDiv"></div>

when i open this page in browser like http://localhost/parent.html it open with button name of getCourseList when i press that button then another.html is loaded in the div getCourseList_innerDiv.Upto now working fine but issue is that when another.html is loaded that inner div that autocomplete does not work so please any one can help me out i will greatfull to you...please

Upvotes: 0

Views: 737

Answers (1)

Abdul Kader
Abdul Kader

Reputation: 5842

Add your autocomplete handler to the document.ready like this

$(document).ready(function(){

$("#course").autocomplete("includes/addcandidate/get_course_list.php", { width: 260, matchContains: true, selectFirst: false }); }); 

});

else add the autocomplete handler on to some live click function like

$("#course").live('click',function(event) {}

Upvotes: 0

Related Questions