i don't mind the functionality change, though i'll admit that i often forget to update web2py_ajax.html and web2py.js on upgrade. if you add a note to the release that contains this to help remind me that would be helpful. :)
On Tuesday, March 23, 2010 6:30:10 AM UTC-7, mdipierro wrote: > > The only problem I see but needs testing is what happens to an > existing app that uses the new SQLFORM with the existing > web2py_ajax.html code? Send me a patch and I will try it. > > On Mar 23, 12:02 am, Jonathan Lundell <jlund...@pobox.com> wrote: > > At the moment, there's a delete-confirmation checkbox that's turned on > when an SQLFORM is 'deletable'. It's a simple checkbox with class='delete', > along with this bit of code in web2py_ajax.html: > > > > > jQuery("input[type='checkbox'].delete").each(function(){jQuery(this).click(function() > > { if(this.checked) if(!confirm("{{=T('Sure you want to delete this > object?')}}")) this.checked=false; });}); > > > > It presents the user with a dialog, and if the use doesn't OK the > dialog, the box isn't checked and no delete occurs on submit. > > > > This logic serves at least two purposes. One, it's a workaround for the > problem that having multiple submit buttons is problematical with IE. Two, > it forces the user to take three actions to delete a record: check the box, > confirm the deletion, and click submit. > > > > I have to alternative suggestions. > > > > One is to move the above jQuery logic into a simple 'onclick' attached > to the checkbox by SQLFORM. This gets rid of the jQuery requirement (with > no loss of functionality), but more important it allows us to have an > option to SQLFORM.__init__() to override the text associated with the > confirmation. 'Sure you want to delete this object?' is somewhat > idiosyncratic English to begin with, but the main problem is that usually > we'd like to be more specific than "this object". Depending on the record, > we might say "this item" or "this item in your cart" or "this user" or any > number of things. > > > > I see no downside to this. It's compatible, and the default action is > identical to the current mechanism. > > > > Alternative: change the delete checkbox to a 'button' element labeled > 'Delete'. Use onclick to attach a confirmation dialog to the button. If the > user confirms, do a submit of the form, but set a hidden variable in the > form to communicate the delete action to accepts. This avoids the IE > problem (there's only one submit button). > > > > Downsides: the UI changes a checkbox to a Delete button, and JavaScript > is required to do a delete at all. > --