Popup client event callbacks

Jul 21, 2011 at 12:14 PM

Hi.

Is there a way to attach some a callback e.g.beforeClose event on the Popup dialog?

For example I use the popup dialog to show a Google map and I want to destroy the map when the dialog closes. This is actually a necessary step when working with google maps and if it not destroyed properly after usage, possible unpredictable issues can occur.

Is this possible with the current version of Awesome framework? Tnx.

Coordinator
Jul 21, 2011 at 1:05 PM

hi,

yes you can write some jquery for this, I did this here:

http://code.google.com/p/prodinner/source/browse/trunk/WebUI/Views/Meal/ChangePicture.ascx

here:

//pchangepicturemeal is the id of the div generated by the html.makepopup
$('#pchangepicturemeal').bind('dialogclose', function () {
if (picChanged) {
picChanged = false;
edit({ Id: $('#id').val() });
}
});
Jul 22, 2011 at 8:33 AM

Yes, I was able to attach a callback to the dialogclose even, however I'm still experiencing problems with the GMAP3 google maps in the popup. I have to research this a little bit better.

Anyway, thank you for your help.

Jul 22, 2011 at 11:45 AM
Edited Jul 22, 2011 at 11:46 AM
Just in case someone wants to uses the popup with dynamically loaded GMAP3 google maps, here is how to do it:
<script>
    function MapApiLoaded() {
        $.getScript("/Scripts/gmap3.min.js", function() {
              // Initialize your map here
         }

    $(document).ready(function () {
        $.getScript("http://maps.google.com/maps/api/js?sensor=false&async=2&callback=MapApiLoaded", function () { });
    });
</script>


Note that this script is located in the Popup View and on document ready we first load the Google Maps API and we give a callback parameter to the MapApiLoaded function which loads the GMAP3 script afterwards and finally within the call back of it we can initialize our GMAP3 map.