Jquery AutoComplete on Mutiple textboxes on ajax populated page

Jquery AutoComplete on Mutiple textboxes on ajax populated page

I have multiple autocomplete textbox in partial view which is working fine when referred from lets say on View 1.On view 1 i have a button ,on click of which i am redirecting to view 2 which also refers this partial view.But here on view 2 ,autocomplete is not working.Then i used the .on function as below, and in this case only one textbox is getting autocomplete while rests are not working. Where i am going wrong.

function PlanAutoComplete() { // debugger $("#txtPlanName").autocomplete({ source: function (request, response) { $.ajax ( //some code here) } }); } function ProductAutoComplete() { // debugger $("#txtProductName").autocomplete({ source: function (request, response) { $.ajax( //some code here ); });

In document.ready i am calling as below.

$(document).ready(function () { $("#txtPlanName").bind("keydown.autocomplete", PlanAutoComplete); $("#txtProductName").bind("keydown.autocomplete", ProductAutoComplete); }

And Also .on function as below

 $('body').on('keydown.autocomplete', '#txtPlanName', PlanAutoComplete); $('body').on('keydown.autocomplete', '#txtProductName', ProductAutoComplete);

Here my first textbox named txtPlanName is working fine ,but the second text is not getting autopopulated.Where i am doing wrong.Please help .