Confirmation Popup on click of button

Oxygen general issues.
sia
Posts: 12
Joined: Tue Sep 17, 2019 1:22 am

Confirmation Popup on click of button

Post by sia »

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: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Confirmation Popup on click of button

Post by alex_jitianu »

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: 12
Joined: Tue Sep 17, 2019 1:22 am

Re: Confirmation Popup on click of button

Post by sia »

Thank You. The solution is working as expected.
Post Reply