that._handleOrderLinks();
that.element.trigger('crmLoad', data);
if (that.options.crmForm) that.element.trigger('crmFormLoad', data);
+ // This is only needed by forms that load via ajax but submit without ajax, e.g. configure contribution page tabs
+ // TODO: remove this when those forms have been converted to use ajax submit
+ if (data.status === 'form_error' && $.isPlainObject(data.errors)) {
+ that.element.trigger('crmFormError', data);
+ $.each(data.errors, function(formElement, msg) {
+ $('[name="'+formElement+'"]', that.element).crmError(msg);
+ });
+ }
}).fail(function(data, msg, status) {
that._onFailure(data, status);
});
}
}
},
- beforeSerialize: function(form, options) {
- if (window.CKEDITOR && window.CKEDITOR.instances) {
- $.each(CKEDITOR.instances, function() {
- if (this.updateElement) this.updateElement();
- });
- }
- if (window.tinyMCE && tinyMCE.editors) {
- $.each(tinyMCE.editors, function() {
- this.save();
- });
- }
- },
beforeSubmit: function(submission) {
$.each(formErrors, function() {
if (this && this.close) this.close();
e.preventDefault();
});
}
- // Show form buttons as part of the dialog
if ($el.data('uiDialog')) {
+ // Show form buttons as part of the dialog
var buttonContainers = '.crm-submit-buttons, .action-link',
buttons = [],
added = [];
$el.parents(buttonContainers).css({height: 0, padding: 0, margin: 0, overflow: 'hidden'}).find('.crm-button-icon').hide();
});
$el.dialog('option', 'buttons', buttons);
+
+ // Show done button for non-ajax dialogs (e.g. file downloads)
+ $(this).on('submit', "form[data-no-ajax-submit=true]", function() {
+ $el.dialog('option', 'buttons', [{
+ text: ts('Done'),
+ icons: {primary: 'ui-icon-close'},
+ click: function() {$(this).dialog('close');}
+ }]);
+ });
}
// Allow a button to prevent ajax submit
$('input[data-no-ajax-submit=true]').click(function() {
.on('dialogcreate', function(e) {
$('.ui-dialog-content.crm-ajax-container:hidden[data-unsaved-changes=true]').crmSnippet('destroy').dialog('destroy').remove();
})
+ // Ensure wysiwyg content is updated prior to ajax submit
+ .on('form-pre-serialize', function(e) {
+ $('.crm-wysiwyg-enabled', e.target).each(function() {
+ CRM.wysiwyg.updateElement(this);
+ });
+ })
// Auto-resize dialogs when loading content
.on('crmLoad dialogopen', 'div.ui-dialog.ui-resizable.crm-container', function(e) {
var