1 Reply Latest reply: Oct 20, 2009 12:02 PM by Arnout Kazemier RSS

    Execute code after Spry region redrawn / added to DOM

    Phil_W Community Member

      Hi,

       

      I'm integrating my Spry event data with a YUI calendar.

       

      Everything is working and event dates are highlighted on the YUI calendar.  There is one last thing I wish to do which is to update the YUI calendar with a Spry Tooltip.  The div regions for the tooltip text are generated dynamically by via a Spry repeating region.  What I am failing to do is attach the tooltips to the YUI calendar after the Spry repeating region has been added to the docuement DOM. So the Spry Tooltip function cannot find the ID of the tooltips.

       

      I have a dataset observer "onpostload" which seems to fire when the data is loaded but before the document dom has been updated by Spry.  How can I ensure I wait for Spry to update the region and hence DOM with the new data before triggering the tooltip code?

       

      Cheers

       

      Phil

        • 1. Re: Execute code after Spry region redrawn / added to DOM
          Arnout Kazemier Community Member

          You got different kind of observers in Spry Data.

           

          - Dataset observers:

               datasetname.addObserver( observer )

           

          - Spry Region Observers:

               Spry.Data.Region.addObserver( 'region-id', observer );

           

          The dataset observers send out notifications when there is a event happening inside the Spry Data Sets. The one you mentioned is part of this (onPostLoad). These are great to monitor your data changes, but in your case. You don't want to use these.

           

          The Spry region observers respond to events that are happening in side the region. For example onPreUpdate, this event is called when the region is about to generate / insert new markup in to your region. But you also got the onPostUpdate. This is the observer you are looking for, it gets called once the region has re-generated its code / html. It gets fired directly after the new HTML has been inserted.

           

          Small note about the region observers, these require a id= attribute. This id attribute must be placed on the same element as the spry:region. To learn, and read more about the observers i would like to referrer you to this article:

           

          Data Set and Region Overview

           

          Its rather large, but using the browser build in find function you should be able to locate the sections about the observers

           

          Hopes this helps,