click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Schellink <sab...@gmail.com>
Subject Re: Submit Link - how to show custom messages?
Date Wed, 22 Apr 2009 19:23:08 GMT
Demetrios Kyriakis wrote:
> 
> E.g. This control is quite practical for deleting something (to have a 
> POST), but usually it requires an confirm dialog to ask the user first.
> deleteLink.setAttribute("onclick", "return window.confirm('Are you sure 
> you want to delete this project?');");
> 
> I think a better approach would be for the component to detect if 
> there's some user event attached, and insert it's own the on-the-fly 
> HTML form building only after the user script.


Good idea. However I don't think it will work to simply append the 
submit code after custom onclick code.

For example:

   <a onclick="return window.confirm('xxx'); alert('hello');"/>

The alert('hello') will never execute because of the leading 'return'.
Normally one will encapsulate the more complex JS in a custom method:

   function confirmSubmit() {
     var x = window.confirm('Confirm?');
     if(x) alert('yay');
     else alert('sniff');
   }

So I suggest we provide a method, say "public String getSubmitScript", 
and document it with a demo example so users know exactly the JS code 
used for submission and can create confirmation dialogs, as long as 
they include the submit script.

regards

bob

Mime
View raw message