I am using the AutoComplete control in tag mode, and I have created a button which will drop down the full tag list, based on some code I found in the forums or knowledgebase somewhere. It works nicely, unless I wrap it in an ajax panel. After a postback, the button no longer works - I get a javascript error: "Unable to get property 'itemDataBound' of undefined or null reference" in jQueryPlugins.js at line 237.
Here is my code:
var autoComplete = $find("<%= tag_box.ClientID %>");
var dropDown = autoComplete._dropDown;
var itemData = autoComplete._dropDownItemData;
setTimeout(function (e) {
dropDown.populate(itemData, true);
dropDown.open(autoComplete._getDropDownPositionInfo());
dropDown.highlightNext();
$('li.racItem').css('display', 'list-item');
}, 200);
The error occurs during the call to 'populate()'
The AutoComplete control works fine by itself after the postback. The tags list is populated, and I can add and remove tags using the keyboard without any fuss.
The script and the AutoComplete are contained in a user control (ascx) which is contained in another user control which has the ajax panel. The script is wrapped in a RadScriptBlock.
I also have two event handlers which I add to the AutoComplete control, like this:
autoComplete.add_entryAdding(tagEntryAdding);
autoComplete.add_entryRemoved(tagEntryRemoved);
The events do not get called after a postback. I set the handlers from a jQuery 'ready' with a small timeout. Works fine before postback. but not after. The 'ready' code gets called (though for some reason I can't catch it in the browser debugger after postback).
I know I am missing something about how ajax and scripts and user controls work together, but I can't figure it out.