Hide last authors
Manuel Smeria 14.4 1 {{toc/}}
Jerome 1.1 2
Simon Urli 18.1 3 {{warning}}
4 Note that for UI consistency point of view, we advise you to prefer using the Bootsrap Modal than this UI Component, in particularly for XWiki Standard development.
5 {{/warning}}
6
Jerome 4.1 7 The Confirmation Box UI is an alternative to the old-fashioned browsers confirm boxes. It displays a nice popup box asking the user to confirm an action. Functions hooks are available on both confirm and cancel actions.
Jerome 1.1 8
Sergiu Dumitriu 14.2 9 //Image of the confirmation box in action~://
Jerome 4.1 10 image:confirmbox.png
11
Jerome 11.1 12 {{html}}
Sergiu Dumitriu 14.3 13 <a href="#" onclick="javascript:new XWiki.widgets.ConfirmationBox();">Or click this link to see one live!</a>
Jerome 11.1 14 {{/html}}
15
Manuel Smeria 14.4 16 = Usage =
Jerome 1.1 17
Jerome 4.1 18 {{code language="javascript"}}
Jerome 10.1 19 new XWiki.widgets.ConfirmationBox(behavior, interactionParameters);
Jerome 1.1 20 {{/code}}
21
Jerome 3.1 22 ; behavior
Manuel Smeria 14.4 23 : \\
Jerome 1.1 24
Manuel Smeria 14.4 25 (((
Sergiu Dumitriu 15.1 26 Object that define confirm and cancel handlers. When the user chooses "Yes", its "onYes" method is triggered if it exists. When the user chooses "No", its "onNo" method is triggered, if it exists. When the user chooses "Cancel", if the cancel button is enabled, its "onCancel" method is triggered, if it exists. The behavior parameter is not mandatory and is empty by default (It means nothing will happen upon confirmation or cancel).
Jerome 1.1 27
Manuel Smeria 14.4 28 Example:
29
Jerome 4.1 30 {{code language="javascript"}}
Jerome 1.1 31 var myBehavior = {
32 onYes: function() {
Sergiu Dumitriu 14.3 33 alert("Yes!");
Jerome 1.1 34 },
35 onNo: function() {
36 alert("Oh no :(");
37 }
Jerome 2.1 38 };
Manuel Smeria 14.4 39 {{/code}}
40 )))
41
Jerome 10.1 42 ; interactionParameters
Manuel Smeria 14.4 43 : \\
Jerome 1.1 44
Manuel Smeria 14.4 45 (((
Sergiu Dumitriu 15.1 46 Object that defines the different text elements displayed within the confirmation box. Five variables are available for customization: **confirmationText** - the message to confirm (default value for the English language is //Are you sure ?//), **yesButtonText** - the "yes" button text (or confirm button), **noButtonText** - the "no" button text, **cancelButtonText** - the "cancel" button text, if enabled, and **showCancelButton** - whether to show the cancel button, disabled by default.
Manuel Smeria 14.4 47
Jerome 2.1 48 Example :
49
Jerome 8.1 50 {{code language="javascript"}}
Jerome 10.2 51 var myInteractionParameters = {
Sergiu Dumitriu 14.3 52 confirmationText: "Are you sure you want to engage the wiki's self-destruction process?",
Sergiu Dumitriu 14.2 53 yesButtonText: "Yes, please do that",
Sergiu Dumitriu 14.3 54 noButtonText: "No thank you"
Jerome 2.1 55 };
Manuel Smeria 14.4 56 {{/code}}
57 )))
Jerome 2.1 58
Manuel Smeria 14.4 59 = Source Code =
Jerome 1.1 60
Sergiu Dumitriu 16.1 61 {{remotecode source="https://raw.github.com/xwiki/xwiki-platform/xwiki-platform-5.4.5/xwiki-platform-core/xwiki-platform-web/src/main/webapp/resources/uicomponents/widgets/confirmationBox.js"/}}
Oana Florea 13.1 62
Manuel Smeria 14.4 63 = Tips =
Oana Florea 13.1 64
65 Check out the Javascript code:
Manuel Smeria 14.4 66
67 * [[for your wiki instance>>http://localhost:8080/xwiki/bin/skin/resources/uicomponents/widgets/confirmationBox.js||rel="__blank"]]
68 * [[from GitHub (for tag xwiki-platform-3.4)>>https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-3.4/xwiki-platform-core/xwiki-platform-web/src/main/webapp/resources/uicomponents/widgets/confirmationBox.js||rel="__blank"]]

Get Connected