PDA

View Full Version : update manager not removed for deleted elements?



sjivan
28 Nov 2006, 7:56 PM
I open a new content panel tab when I double-click on a table row. When the content panel opens, I attach a listener to the 'update' event of the UpdateManager of the new (ContntPanel) div. The attached listener is invoked as expected the UpdateManager completes the update.

Now I close the tab and hence the div of this tab is removed from the DOM. I reopen this tab and as usual a listener is attached to the UpdateManager of the ContentPanel div. The strange thing that I'm observing is that the listener now gets invoked twice although the old UpdateManager was listening on the update of a div (with same id) that no longer exists.

So it appears that the UpdateManager subscriptions are somehow being tied to the element ID and not necessarily to the element object. Can you confirm? Does the element caching in YAHOO.ext.Element.get have something to do with this?

How do I resolve this issue?

I read http://www.yui-ext.com/forum/viewtopic.php?t=281 which describes a similar problem. In my case however I cannot call removeListener as I'm dealing with a different 'this' each time a tab is opened because I open a tab when a row is clicked and I cannot keep the object instance managing this tab around after the tab is closed.

Any suggestions?

Thanks,
Sanjiv

jack.slocum
29 Nov 2006, 5:38 AM
Yes, that is exactly what is happening. The Element object is caching and when you change the element with a new element with the same id, it will auto refresh the dom object to the new object.

What you are looking for isn't an event - the event is what you would want if you wanted to constantly listen for any updates - instead it appears you want a callback. There is a parameter on update and formUpdate that will allow you to pass in a callback.

sjivan
29 Nov 2006, 6:53 AM
aha, with a callback things work better. The one issue i'm still facing with the callback appraoch is that when the new ContentPanel dispalys, I see the vanilla response (a bunch of divs) for a split second before it then displays into tabs via the code in my callback function.

I was able to avoid this flicker in the listener approach my adding a YAHOO.ext.util.DelayedTask , but I cant seen to avoid this flicker with the callback appraoch.

Thanks,
Sanjiv

jack.slocum
29 Nov 2006, 7:20 AM
Set the divs to visibility hidden. The tab component will remove it once they are loaded.

sjivan
29 Nov 2006, 7:43 AM
I should have figured that one out. Next time i'll work on a problem some more before posting. I dont want to take advantage of your willingness to help :)

sjivan
2 Dec 2006, 8:48 AM
Set the divs to visibility hidden. The tab component will remove it once they are loaded.

I noticed that the tabs example has the class declaration "tab-content" which sets display none.

.tab-content{display:none;}

Does it make sense to add this to the yui-ext tabs.css file since users would almost always want this with dynamically fetched content with tabs.

Sanjiv

jack.slocum
2 Dec 2006, 9:32 AM
No that's actually old code. If anything it should be visibility:hidden;position:absolute;top:0;

The TabPanel component doesn't use display:none anymore (it does fix items started with display:none though).