Merge pull request #15673 from eileenmcnaughton/set
[civicrm-core.git] / js / crm.multilingual.js
index ced31483b764ea3c3219ec6ae201d5f9ebc7c31b..f3af7145d4046aded1ced7c9759da94eff61df24 100644 (file)
@@ -7,18 +7,21 @@ CRM.$(function($) {
   $('body').on('click', 'a.crm-multilingual-edit-button', function(e) {
     var $el = $(this),
       $form = $el.closest('form'),
-      $field = $('#' + $el.data('field'), $form);
+      $field = $('#' + $el.data('field'), $form),
+      wysiwyg = $field.hasClass('crm-form-wysiwyg');
 
     CRM.loadForm($el.attr('href'), {
       dialog: {width: '50%', height: '50%'}
     })
       // Sync the primary language field with what the user has entered on the main form
       .on('crmFormLoad', function() {
-        $('.default-lang', this).val($field.val());
+        CRM.wysiwyg.setVal($('.default-lang', this), CRM.wysiwyg.getVal($field));
+        $('.default-lang', this).triggerHandler('change');
       })
       .on('crmFormSubmit', function() {
         // Sync the primary language field with what the user has entered in the popup
-        $field.val($('.default-lang', this).val());
+        CRM.wysiwyg.setVal($field, CRM.wysiwyg.getVal($('.default-lang', this)));
+        $field.triggerHandler('change');
         $el.trigger('crmPopupFormSuccess');
       });
     e.preventDefault();