[SOLVED] Custom field Editor (TinyMCE) text disappears when dragged/sorted

Started by AbsoluteVM, February 20, 2013, 12:41:32 PM

Previous topic - Next topic

AbsoluteVM

Hello.

I had an issue with the tinyMCE editor disappearing when I dragged it. tinyMCE does not like to be played with in the DOM, but gladly VM2 uses 'Sortable' plugin which comes with some useful 'start' and 'stop' functions.

This is a core hack until the VM2 team choose to implement it into a release, and is below

administrator/components/com_virtuemart/views/product/tmpl/product_edit_custom.php

Replace:
jQuery(document).ready(function(){
jQuery('#custom_field').sortable();
// Need to declare the update routine outside the sortable() function so
// that it can be called when adding new customfields
jQuery('#custom_field').bind('sortupdate', function(event, ui) {
jQuery(this).find('.ordering').each(function(index,element) {
jQuery(element).val(index);
//console.log(index+' ');

});
});
});


With:
// BEGIN CORE HACK - Refresh sortable UI with tinyMCE
jQuery(document).ready(function(){
jQuery('#custom_field').sortable({
start: function(e, ui){
    jQuery(this).find('.removable textarea').each(function(){
        tinyMCE.execCommand('mceRemoveControl', false, jQuery(this).attr('id'));
    });
},
stop: function(e,ui) {
    jQuery(this).find('.removable textarea').each(function(){
        tinyMCE.execCommand( 'mceAddControl', false, jQuery(this).attr('id') );
        jQuery(this).sortable('refresh');
    });
}
});
});


Happy coding.