struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pablo Vázquez Blázquez <pvazq...@denodo.com>
Subject Re: Struts2 + Dojo 0.4 + unbeforeunload problem
Date Fri, 12 Sep 2008 07:33:45 GMT
<script type="text/javascript">
    var form = document.forms[0];
    if ((form) &amp;&amp; (formIsDirty(form))) {
        var a = confirm("There are unsaved changes. Do you want to 
continue?");
        if (!a) {
            dojo.event.topic.publish("/cancelNavigation");
           //HOW TO CANCEL NAVIGATION??
        }
    }
   
    onbeforeunload = function(e) {
        if (formIsDirty(document.forms[0])) {
            e.returnValue = "There are unsaved changes.";
        }
    }
</script>

When calling topic "/cancelNavigation" the event paremeter is 
undefined... Do you know any way to cancel navigation? I mean, cancel 
rendering the served page.


Jeromy Evans escribió:
> Pablo Vázquez Blázquez wrote:
>> Using dojo.addOnUnload(function) neither works. Besides that, I would 
>> need sht like dojo.addOnBeforeUnload, but it does not exist.
>>
>> I don´t think I should subscribe for an ajax-request-completion 
>> event, but for the beforeunload one, don´t I?
>>
>> Thanks.
>
> Use the dojo.connect function to listen to an arbitrary event.  See 
> the comments to this related post: 
> http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/when-does-unload-event-get-fired

>
>
> I don't use it myself. Just pointing you in the right direction.
>
> Also, if the script is inline within your ajax response, see the 
> recently updated notes on Handling AJAX Responses here:
> http://struts.apache.org/2.x/docs/ajax-tags.html
> (its written for 2.1 but mostly applies)
> I'd consider turning on separateScritpts as well.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message