var dialog = popup(url, settings);
// Trigger events from the dialog on the original link element
$el.trigger('crmPopupOpen', [dialog]);
- // Buffer this event so it only fires once
- dialog.on('crmFormSuccess.crmPopup', function(e, data) {
+ // Listen for success events and buffer them so we only trigger once
+ dialog.on('crmFormSuccess.crmPopup crmPopupFormSuccess.crmPopup', function() {
formSuccess = true;
});
dialog.on('dialogclose.crmPopup', function(e, data) {
// https://civicrm.org/licensing
// Enable administrators to edit option lists in a dialog
jQuery(function($) {
- var optionsChanged;
$('body')
// Edit option lists
.on('click', 'a.crm-option-edit-link', CRM.popup)
- .on('crmPopupOpen crmPopupFormSuccess', 'a.crm-option-edit-link', function(e) {
- optionsChanged = e.type === 'crmPopupFormSuccess';
- })
- .on('crmPopupClose', 'a.crm-option-edit-link', function() {
- if (optionsChanged) {
- $(this).trigger('crmOptionsEdited');
- var $elects = $('select[data-option-edit-path="' + $(this).data('option-edit-path') + '"]');
- if ($elects.data('api-entity') && $elects.data('api-field')) {
- CRM.api3($elects.data('api-entity'), 'getoptions', {sequential: 1, field: $elects.data('api-field')})
- .done(function (data) {
- CRM.utils.setOptions($elects, data.values);
- });
- }
+ .on('crmPopupFormSuccess', 'a.crm-option-edit-link', function() {
+ $(this).trigger('crmOptionsEdited');
+ var $elects = $('select[data-option-edit-path="' + $(this).data('option-edit-path') + '"]');
+ if ($elects.data('api-entity') && $elects.data('api-field')) {
+ CRM.api3($elects.data('api-entity'), 'getoptions', {sequential: 1, field: $elects.data('api-field')})
+ .done(function (data) {
+ CRM.utils.setOptions($elects, data.values);
+ });
}
- })
+ });
});
<script type="text/javascript">
{literal}
CRM.$(function($) {
- $('a.delete-attachment').click(function() {
+ $('a.delete-attachment').click(function(e) {
var $el = $(this),
$row = $el.closest('.crm-attachment-wrapper'),
msg = '{/literal}{ts escape="js" 1="%1"}This will immediately delete the file %1. This action cannot be undone.{/ts}{literal}';
var request = $.post(postUrl, $el.data('args'));
CRM.status({success: '{/literal}{ts escape="js"}Removed{/ts}{literal}'}, request);
request.done(function() {
+ $el.trigger('crmPopupFormSuccess');
$row.remove();
});
});
- return false;
+ e.preventDefault();
});
});
{/literal}