Attachment Picker WebJar
Last modified by Admin on 2024/03/25 16:27
JavaScript resources required by the attachment picker module. |
Type | webjar |
Category | API |
Developed by | |
Active Installs | 92 |
Rating | |
License | GNU Lesser General Public License 2.1 |
Bundled With | XWiki Standard |
Compatibility | 14.4RC1+ |
Table of contents
Description
This extension provides the Javascript code for the Attachment Picker Macro.
It also provide events to interact with the attachment picker from some external Javascript code.
Events
- xwiki:attachmentGalleryPicker:selected: Send when an attachment is selected. The attachment reference of the selected attachment is passed as the first parameter.
- xwiki:attachmentGalleryPicker:unselected: Send when an attachment is unselected.
Example
Let say the following attachment grid picker is declared.
{{attachmentGalleryPicker id="myid"/}}
It is possible to observe the events send by the macro using the snippet below;
require(['jquery'], function($) {
// selects the macro by its id.
const picker = $('#myid')
// Listen for selected attachment events.
picker.on('xwiki:attachmentGalleryPicker:selected', function(_target, attachmentReference) {
// TODO: do something with the attachment reference.
});
// Listen for unselected attachment events.
picker.on('xwiki:attachmentGalleryPicker:unselected', function() {
// TODO: react to the attachment being unselected.
});
});
// selects the macro by its id.
const picker = $('#myid')
// Listen for selected attachment events.
picker.on('xwiki:attachmentGalleryPicker:selected', function(_target, attachmentReference) {
// TODO: do something with the attachment reference.
});
// Listen for unselected attachment events.
picker.on('xwiki:attachmentGalleryPicker:unselected', function() {
// TODO: react to the attachment being unselected.
});
});
Dependencies
Dependencies for this extension (org.xwiki.platform:xwiki-platform-attachment-picker-webjar 16.2.0):
- org.webjars:requirejs 2.3.6
- org.webjars:jquery 3.7.1
- org.xwiki.platform:xwiki-platform-search-solr-query 16.2.0
- org.xwiki.platform:xwiki-platform-localization-webjar 16.2.0
- org.xwiki.platform:xwiki-platform-localization-rest-api 16.2.0