Yes, that appears to be a bug. web2y_ajax_init() (in 
/static/js/web2py_ajax.js) is called when the page is first loaded as well 
as whenever a new component is loaded. That function binds a number of 
event handlers, so every time it is called, it binds additional identical 
event handlers to the same elements (and because it uses .live() to do the 
binding, even components loaded later will add event handlers to components 
loaded earlier). If you're clicking 8 times to dismiss the OK, I'm guessing 
you've got 7 components on the page (i.e., web2py_ajax_init() is called 8 
times, including when the main page is loaded, so adds the event handler 8 
times).

I'm working on a more general fix (so calls to web2py_ajax_init() will only 
bind events for elements within the component being loaded), but a quick 
short-term fix is to replace:

  jQuery("input[type='checkbox'].delete").live('click', function(){ 
if(this.checked) if(!confirm(confirm_message)) this.checked=false; });

with:

  jQuery("input[type='checkbox'].delete").live('click', function(e){ 
if(this.checked) if(!confirm(confirm_message)) this.checked=false; 
e.stopImmediatePropagation(); });

Note, that will prevent you from being able to attach any other event 
handlers that would trigger after the checkbox click because it stops the 
event propagation.

Anthony

On Monday, October 31, 2011 9:43:42 AM UTC-4, glimmung wrote:
>
> Hi,
>
> I've converted some fiddly admin pages to use web2py's Ajax components, 
> which has simplified them enormously.
>
> However, where I'm using CRUD update forms and deleteable=True, the 
> delete confirmation pop-up does not work as expected.
>
> I do see the "Are you sure you want to delete this object?" pop-up, but 
> it only responds immediately to the "cancel" button - "cancel" clears 
> the dialogue and leaves the checkbox unchecked, "OK" does not initially 
> appear to respond. However, if I click "OK" multiple times (8-ish) it 
> eventually clears and sets the checkbox checked.
>
> Am I missing something obvious?
>
> I'm somewhat at a loss as to how to troubleshoot this one - I've been 
> spoiled by web2py's usual "just works" behaviour!
>
>
> -- 
>
> Regards,
>
> PhilK
>
>
> 'a bell is a cup...until it is struck'
>
>

Reply via email to