Jump to content
Stef's Coding Community

WYSIWYG Editor Issue


Recommended Posts

HI Guys,

 

Just wondering if anyone got this issue that I have been having, sometimes when i paste content directly into tinymce and try to input more content after the part pasted prior it does not update the database. Even if i safely paste the content in by pressing the paste button, I still get this issue.

 

It doesn't happen all the time, just every so often... Checked the entire cms and cannot spot any errors.

 

the code for Tiny MCE within the v_edit file is the following

<!-- jQuery Block Start-->
<!-- jQuery is used to catch the forms submit process -->
<script type="text/javascript">
   jQuery(document).ready(function($){

       $('#edit').submit(function(e){
           //Disable the default browser refresh
           e.preventDefault();

           //Ajax to process the form
           var id = "<?php echo $this->getData('block_id')?>";
           var type = $('#type').val();

           //This is for TinyMCE Ajax
           <?php if($this->getData('block_type') == 'wysiwyg') {?>
               tinyMCE.triggerSave();
           <?php }?>

           var content = $('#field').val();

           //Passing the values onto Ajax
           var dataString = 'id=' + id + '&field=' + content + '&type=' +type;

           //Call ajax
           $.ajax({
               type: "POST",
               url: "<?php echo SITE_PATH; ?>app/cms/edit.php",
               data: dataString,
               cache: false,
               success: function(html) {
                   $('#cboxLoadedContent').html(html);
               }
           });
       });

       //jQuery to close the box
       $('#fs_cancel').live('click', function(e){
           //This is addressing the issue with open close then reopen issue
           if(tinyMCE.getInstanceById('field'))
               {
                   tinyMCE.execCommand('mceFocus', false, 'field');
                   tinyMCE.execCommand('mceRemoveControl', false, 'field');
               }
       });

   });
</script>
<?php if($this->getData('block_type') == 'wysiwyg')
{ ?>

       <script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "none",

		skin : "thebigreason",

		theme : "advanced",
		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,\n\
                                  preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,\n\
                                  visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,vimeo,jbimages",

		// Theme options
		theme_advanced_buttons1 : "fontsizeselect,bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,\n\
                                                  justifyfull,link,unlink,paste,pasteword,pastetext,fullscreen,undo,redo,forecolor,backcolor,\n\
                                                  code,vimeo,jbimages",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "sub,sup,|,charmap,iespell,advhr,",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		height:"300",
                       width:"700"
	});
               //once again below is to load the editor addressing open close issue
               setTimeout(function() {tinyMCE.execCommand('mceAddControl', false, 'field');}, 0);
</script>

<? }?>


<!-- jQuery Block End-->


<div id="fs_wrapper">
      <form action="" method="post" id="edit">

             <div class="row">
                <h1>Edit Content <?php // echo $this->getData('block_id'); ?></h1>
                <p>Click and edit below</p>
             </div>

            <div class="row">
              <?php echo $this->getData('cms_field');?>
              <input type="hidden" id="type" value="<?php $this->getData('block_type');?>">
            </div>
            <br/>
            <input type="submit" name="submit" class="green_button" value="Submit">
            <br/><br/>
            <a href="#" id="fs_cancel">Cancel</a>
      </form>

 

If anyone could help that would be great.

 

Kind Regards

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...