jquery autocomplete works initially but fails after redraw

I uploaded an image to help explain... called autocompleteproblem.gif but not sure where that shows up...

I am using jorn version of jquery autocomplete and have a problem.
I have a page that has a div containing a form (and my auto complete field). Initially, this div is populated when the page is drawn, however, the user can trigger an ajax request that, upon returning, refills the contents of the div with updated info.
On The initial load, my autocomplete field works great. However, after the div contents are reloaded via ajax... nothing happens when i type in my auto complete field.

I placed an alert() into autocomplete.js in the function onChange(crap, skipPrevCheck) {. On initial load, when i type in my field, i get the alert. however, the alert does not fire the second time.

something to note... in my ajax callback, when I am refilling the contents of the div via ajax, I am using innerHTML to set the contents... I have to escape quotes etc.
e.g. mydiv.innerHTML="the entire form including my autocomplete field"

is there something to do with the dom ... or CSS... where a pointer to my autocomplete field is created initially... then when the new version of the div tries to do it again... there is a conflict?
Obviously I am very new to this stuff...
$("#item_num").autocomplete(
    "http://myurl.com&",
     {
    delay:400,
    minChars:2,
    matchSubset:1,
    maxItemsToShow:12,
    matchContains:1,
    extraParams:{mytype:function() {return formPartsUsed.request_type[0].checked;},itemnum:function() {return formPartsUsed.item_num.value;}},
    hideCallback : function() {document.getElementById("pleasewait").style.visibility="hidden";},
    cacheLength:0,
    onItemSelect:selectItem,
    autoFill:false
  }
);
 
 
Here is a simplified example: (Oracle Pl/SQL)
----INITIAL PAGE LOAD---
<div id=mydiv>
<form name=form1 method=post action="ajax post">
<input type=text class="ac_input" alt="Item#" name="item_num" id="item_num">
<input type=button onclick="form1.submit();">
... more div content
</form>
</div>
 
---AJAX REQUEST CALLBACK (replaces the div with new results.)---
strContent := '<form name=form1 method=post action="ajax post">';
strContent := strContent || '<input type=text class="ac_input" alt="Item#" name="item_num" id="item_num">';
strContent := strContent || '<input type=button onclick="form1.submit();">';
strContent := strContent || '... more div content';
document.getElementById("mydiv").innerHTML=REPLACE(strContent,'"','\"');

Open in new window

ericdalrympleAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
Not sure you want to submit that form - it could unload the page

Why not call the ajax submit from the button instead?
0
ericdalrympleAuthor Commented:
The page has tabs. I have a single div that holds the contents of a tab. When user clicks on a different tab I use Ajax to get the contents for that tab and fill the div... Not really doing a form submit... Using Ajax to retrieve contents of div.
When the page draws initially, my div that contains the autocomplete field works fine. When I grab the exact same contents and fill the div(user clicked a different tab then returns to original tab) it stops working.
0
ericdalrympleAuthor Commented:
trying this attach file functionality again... dont see where it can be viewed from the first time i did it.
autocompleteproblem.jpg
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Michel PlungjanIT ExpertCommented:
This sure looks like a submit to me
onclick="form1.submit();"
0
ericdalrympleAuthor Commented:
i just put the button with submit as an example... sorry... when the user changes tabs it fires off the ajax below. When it comes back it makes the div visible and innerHTML the contents of the tab.

anyway... the problem is that after this is done... the autocomplete stops working.

thanks for your reply...
function getPartsRemoved(){
//hide the div
document.getElementById("bottomTabDiv").style.visibility="hidden";
var sFrmData = "";
var sURL="myurl";
doAjax(sURL,sFrmData);
}
 
function doAjax(sURL,sFrmData){';
$.ajax({
    type: "POST",
    url: sURL,
    data: sFrmData,
    success: function(ajaxResponse){
    eval(ajaxResponse);
  }
 });	
}		

Open in new window

0
ericdalrympleAuthor Commented:
I just recoded everything to not refresh the tab where the autocomplete field lives. Still an issue but I worked around it for now.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.