How to update yui menu positions after an ajax page insertion?
I've got a page with a bunch of items on it. Each item has a widget that, when clicked, brings up a YUI popup-style menu of options. So far, this is working fine.
I'm using jQuery/ajax calls to insert new items into the page, pushi开发者_开发知识库ng existing items down. The items are being inserted correctly, but I now have to update, somehow, the positions of the items' popup menus to match the new positions of the widgets that invoke them. As far as I can tell, they're computed as page coordinates and stored away with the menu objects when the page is rendered, and are not automatically updated by the ajax insertions.
This is where my problem is: I've tried some jQuery that, for each menu, recomputes the menu item, does a removeListener() to kill the old menu, and does an addListener() to insert what should be the new one. This properly updates the positions of the menus when they're invoked, but breaks something else: If I click on a widget and bring up a menu, and then click somewhere else on the page, the menu stays on the screen instead of disappearing. I can click on other widgets and they, too, will appear. Notes: no errors show up in the console; hitting the ESCAPE key during the menu presentation still correctly hides the menu.
There must be a way to do this, but I'm lost. Any clues? Perhaps all I really need to do is update the context information of the menu; is there a way to do that without the delete-and-add listener sequence that seems to be screwing me up? Thanks!
All continues to be well as noted in the updates; I'm declaring this to be answered.
精彩评论