How can I call the delete confirmation dialog from the grid's selectable buttons?

28 views
Skip to first unread message

João Matos

unread,
Mar 13, 2019, 5:15:11 PM3/13/19
to web2py-users
Hello,

How can I call the delete confirmation dialog from one of the grid's selectable buttons?

Thanks,

JM

João Matos

unread,
Mar 14, 2019, 8:35:13 AM3/14/19
to web2py-users
I found a solution. I bit "insane", but it works.

I post it here so that it can help others.

In the function responsible for the the grid's selectable button action I redirect to itself with the grid selection as a request.var.

redirect(URL(vars={'id': ids[0]}, user_signature=True))

Then on the original page, I added this code at the bottom of the page.

{{if request.vars and request.vars.id:}}
<script><!--
    window.onload = function ask_for_confirmation() {
        var r = confirm("{{=T('Are you sure you want to delete this object?')}}");
        if (r == true) {
            window.location.href = "{{=URL('open_wo', 'delete_after_confirmation_approval_not_required', args=[request.vars.id], user_signature=True)}}";
        }
    }
//--></script>
{{pass}}
Reply all
Reply to author
Forward
0 new messages