Confirmation forms. The book is unclear. How can I associate a pop confirmation box with a link?

39 views
Skip to first unread message

dgm...@gmail.com

unread,
May 2, 2019, 3:58:02 PM5/2/19
to web2py-users
This has been asked before but I can't find any usable answers, at least for those who aren't experts on css and javascript.

Tried to do something along the lines suggested in the book 'Forms and Validators/Confirmation Forms' without any success. Either I'm stupid or this feature is broken or the explanation is incomplete/unhelpful.

Actually, my problem is a bit different. I am using SQLFORM.grid and .smartgrid, with additional links specified. On one of these links I would like to have a confirming Yes/No when the link is clicked, before following the link. It almost looks in the documentation if this could be done using the A() helper, but I can't figure it out. My link is a replacement for the standard Delete button because there is other stuff that needs to be done BEFORE the deletion is performed, rather than after via ondelete.

John Bannister

unread,
May 3, 2019, 3:59:26 AM5/3/19
to web...@googlegroups.com

I came across the same issue recently and managed to solve it as follows:-

 

lambda row: A(SPAN('Delete', _class="button btn btn-info btn-sm", _title='Delete', _onclick = "return confirm('Are you sure?');"), \

                             _href=URL("default", "delete_company",args=[row.id])),

          

This will give you the standard pop confirmation box with customised text.

 

Hope this helps.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages