jquery - TinyMCE Image upload not working in IE9 & IE10 -


the following code using uploading image in tinymce , not working in ie9,ie10,please me solve this

      editor.addbutton('imageinsert', {                         title : 'insert image',                         image : '<?php echo yii::app()->request->baseurl; ?>/images/image-icon.png',                           onclick : function(e) {                                  e.preventdefault();                                 if ($.browser.msie)                                 {                                     $('#tinymce-image-upload').click(function(){                                         settimeout(function()                                               {                                                   if($input.val().length > 0) {                                                     uploadimage(editor,e);                                                   }                                               }, 0);                                      });                                 }                                                                   else{                                  $('#tinymce-image-upload').click();                                  $('#tinymce-image-upload').change(function(event){                                        event.preventdefault();                  uploadimage(editor,e);                                  });                                 }                        }         }); 

now done using integrating fancy box tinymce steps are:

  1. add custom image button in tiny mce.
  2. when click on button fancy box displayed input file box
  3. jquery used uploading the image server after uploading image image displayed in tinymce , fancy box close.

code:

script :

tinymce.init({     selector: "textarea#merchantsemailmarketing_email_body",     theme: "modern",   readonly : parseint($("#viewaccess").val()),     menubar: false, statusbar: false, force_p_newlines: false,relative_urls:true,     height: 405,     convert_urls: false,     init_instance_callback:function(){       ac = tinymce.activeeditor;        var links = tinymce.activeeditor.getdoc().getelementsbytagname("a");       (i = 0; < links.length; i++) {          links[i].setattribute("onclick", "return false");       }     },      plugins: [          "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",          "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",          "save table contextmenu directionality emoticons template paste textcolor "    ],    content_css: "css/content.css",    toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link  |  imageinsert | forecolor backcolor ",     style_formats: [         {title: 'bold text', inline: 'b'},         {title: 'red text', inline: 'span', styles: {color: '#ff0000'}},         {title: 'example 1', inline: 'span', classes: 'example1'},         {title: 'example 2', inline: 'span', classes: 'example2'},         {title: 'table styles'},         {title: 'table row 1', selector: 'tr', classes: 'tablerow1'}     ],             setup: function(editor) {               editor.addbutton('imageinsert', {                                 title : 'insert image',                                 image : '<?php echo yii::app()->request->baseurl; ?>/images/image-icon.png',                                   onclick : function(e) {                                     $('#tinymce-image-upload').val('');                                   $(".fancybox-for-file-upload").fancybox({                                         'padding': 0,                                         'margin': 0,                                         'autoscale': true,                                   });                                    $(".fancybox-for-file-upload").click();                                   }                 });      } }); 

html fancy box (need add library of fancy box , jquery image upload):

<!-- upload view -->     <a href="#file-upload-window" class="fancybox-for-file-upload"></a>     <div style="display:none" class="popup-wrappeer"  >         <div id="file-upload-window"  class="sow-popup-content-wrap" style="background-color:#fff4df;width:500px;height:130px" >               <h3 style="white-space:nowrap;">                   <?php echo yii::t(yii::app()->session['translator'], 'merchant_messaging_file_not_selected') ?>                   <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>                   <hr color="#ddb25b" size="1"/>                      </h3>                <?php                 $form = $this->beginwidget('cactiveform', array(                     'id' => 'createdeal-form',                     'enableajaxvalidation' => false,                     'enableclientvalidation' => true,                     'htmloptions' => array(                         'enctype' => 'multipart/form-data',                     ),                 ));                 ?>                   <div id='dealpreview' class="formdeal_img_holder"> </div>                    <div class="formdeal_img_selector">                               <input type="file" name="email_image" id="email_image" />                    </div>                  </div>                    <div id="image_error" class="errormessage" "></div>                 <?php $this->endwidget(); ?>         </div>     </div>     <!-- end upload view --> 

code display image in tinymce

var image = '<img  src="'+ data +'" >';  // data contain image url                   tinymce.activeeditor.execcommand('mceinsertcontent',true, image);                   $.fancybox.close(); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -