Confirmation Popup on click of button

<oXygen/> general issues.
sia
Posts: 8
Joined: Tue Sep 17, 2019 1:22 am

Confirmation Popup on click of button

Post by sia » Wed Oct 16, 2019 1:18 am

Hello all,

Is there anyway to put up a confirmation popup on click of button and then on "yes"- say delete the desired element and for "No" - do nothing ?
Thank you.

Regards,
Sia

alex_jitianu
Posts: 705
Joined: Wed Nov 16, 2005 11:11 am

Re: Confirmation Popup on click of button

Post by alex_jitianu » Thu Oct 17, 2019 2:04 pm

Hello,

The fastest way I can think of is with an XQuery Update script that uses a bit of Java reflection to present a dialog:

Code: Select all

declare namespace jop = "java:javax.swing.JOptionPane";

let $result := jop:showConfirmDialog(null, "Delete element", "Confirm", 0)

return if ($result = 0) then (
  delete node .
) else ()

The button is added like this:

Code: Select all

element:after {
    content: oxy_action(
          name, 'Delete', 
          description, 'Delete', 
          operation, 'XQueryUpdateOperation', 
          arg-script, oxy_url('delete.xquery')
)

}
In this example the script sits in a file named delete.xquery, next to the CSS.

Another option would be to create a custom author operation that present the dialog and removes the fragment as well.

Best regards,
Alex

sia
Posts: 8
Joined: Tue Sep 17, 2019 1:22 am

Re: Confirmation Popup on click of button

Post by sia » Tue Oct 22, 2019 11:16 pm

Thank You. The solution is working as expected.

Post Reply