javascript - Uncaught TypeError: Object #<error> has no method 'get' in Chrome -


i have link onclick function:

<a id="content-tmce" class="wp-switch-editor switch-tmce" onclick="return_tinymce_status();">visual</a> 

when clicked, editor load tinymce again (from original codemirror environment). return_tinymce_status function:

function return_tinymce_status() {      if (!(window.tinymce)) {                 window.tinymce=tinymce;     }  } 

in firefox, when click link, working fine without errors in js console. in chrome, this:

uncaught typeerror: object #<error> has no method 'get' 

any special handling js window in chrome? or missing simple here? points error to:

var switcheditors={switchto:function(b){var c=b.id,a=c.length,e=c.substr(0,a-5),d=c.substr(a-4);this.go(e,d)},go:function(g,f){g=g||"content";f=f||"toggle";var c=this,b=tinymce.get(g),a,d,e=tinymce.dom;a="wp-"+g+"-wrap";d=e.get(g);if("toggle"==f){if(b&&!b.ishidden()){f="html"}else{f="tmce"}}if("tmce"==f||"tinymce"==f){if(b&&!b.ishidden()){return false}if(typeof(qtags)!="undefined"){qtags.closealltags(g)}if(tinymcepreinit.mceinit[g]&&tinymcepreinit.mceinit[g].wpautop){d.value=c.wpautop(d.value)}if(b){b.show()}else{b=new tinymce.editor(g,tinymcepreinit.mceinit[g]);b.render()}e.removeclass(a,"html-active");e.addclass(a,"tmce-active");setusersetting("editor","tinymce")}else{if("html"==f){if(b&&b.ishidden()){return false}if(b){b.hide()}e.removeclass(a,"tmce-active");e.addclass(a,"html-active");setusersetting("editor","html")}}return false},_wp_nop:function(c){var d,b,e=false,a=false;if(c.indexof("<pre")!=-1||c.indexof("<script")!=-1){e=true;c=c.replace(/<(pre|script)[^>]*>[\s\s]+?<\/\1>/g,function(f){f=f.replace(/<br ?\/?>(\r\n|\n)?/g,"<wp-temp-lb>");return f.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"<wp-temp-lb>")})}if(c.indexof("[caption")!=-1){a=true;c=c.replace(/\[caption[\s\s]+?\[\/caption\]/g,function(f){return f.replace(/<br([^>]*)>/g,"<wp-temp-br$1>").replace(/[\r\n\t]+/,"")})}d="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset";c=c.replace(new regexp("\\s*</("+d+")>\\s*","g"),"</$1>\n");c=c.replace(new regexp("\\s*<((?:"+d+")(?: [^>]*)?)>","g"),"\n<$1>");c=c.replace(/(<p [^>]+>.*?)<\/p>/g,"$1</p#>");c=c.replace(/<div( [^>]*)?>\s*<p>/gi,"<div$1>\n\n");c=c.replace(/\s*<p>/gi,"");c=c.replace(/\s*<\/p>\s*/gi,"\n\n");c=c.replace(/\n[\s\u00a0]+\n/g,"\n\n");c=c.replace(/\s*<br ?\/?>\s*/gi,"\n");c=c.replace(/\s*<div/g,"\n<div");c=c.replace(/<\/div>\s*/g,"</div>\n");c=c.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi,"\n\n[caption$1[/caption]\n\n");c=c.replace(/caption\]\n\n+\[caption/g,"caption]\n\n[caption");b="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset";c=c.replace(new regexp("\\s*<((?:"+b+")(?: [^>]*)?)\\s*>","g"),"\n<$1>");c=c.replace(new regexp("\\s*</("+b+")>\\s*","g"),"</$1>\n");c=c.replace(/<li([^>]*)>/g,"\t<li$1>");if(c.indexof("<hr")!=-1){c=c.replace(/\s*<hr( [^>]*)?>\s*/g,"\n\n<hr$1>\n\n")}if(c.indexof("<object")!=-1){c=c.replace(/<object[\s\s]+?<\/object>/g,function(f){return f.replace(/[\r\n]+/g,"")})}c=c.replace(/<\/p#>/g,"</p>\n");c=c.replace(/\s*(<p [^>]+>[\s\s]*?<\/p>)/g,"\n$1");c=c.replace(/^\s+/,"");c=c.replace(/[\s\u00a0]+$/,"");if(e){c=c.replace(/<wp-temp-lb>/g,"\n")}if(a){c=c.replace(/<wp-temp-br([^>]*)>/g,"<br$1>")}return c},_wp_autop:function(a){var c=false,b=false,d="table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|noscript|samp|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary";if(a.indexof("<object")!=-1){a=a.replace(/<object[\s\s]+?<\/object>/g,function(e){return e.replace(/[\r\n]+/g,"")})}a=a.replace(/<[^<>]+>/g,function(e){return e.replace(/[\r\n]+/g," ")});if(a.indexof("<pre")!=-1||a.indexof("<script")!=-1){c=true;a=a.replace(/<(pre|script)[^>]*>[\s\s]+?<\/\1>/g,function(e){return e.replace(/(\r\n|\n)/g,"<wp-temp-lb>")})}if(a.indexof("[caption")!=-1){b=true;a=a.replace(/\[caption[\s\s]+?\[\/caption\]/g,function(e){e=e.replace(/<br([^>]*)>/g,"<wp-temp-br$1>");e=e.replace(/<[a-za-z0-9]+( [^<>]+)?>/g,function(f){return f.replace(/[\r\n\t]+/," ")});return e.replace(/\s*\n\s*/g,"<wp-temp-br />")})}a=a+"\n\n";a=a.replace(/<br \/>\s*<br \/>/gi,"\n\n");a=a.replace(new regexp("(<(?:"+d+")(?: [^>]*)?>)","gi"),"\n$1");a=a.replace(new regexp("(</(?:"+d+")>)","gi"),"$1\n\n");a=a.replace(/<hr( [^>]*)?>/gi,"<hr$1>\n\n");a=a.replace(/\r\n|\r/g,"\n");a=a.replace(/\n\s*\n+/g,"\n\n");a=a.replace(/([\s\s]+?)\n\n/g,"<p>$1</p>\n");a=a.replace(/<p>\s*?<\/p>/gi,"");a=a.replace(new regexp("<p>\\s*(</?(?:"+d+")(?: [^>]*)?>)\\s*</p>","gi"),"$1");a=a.replace(/<p>(<li.+?)<\/p>/gi,"$1");a=a.replace(/<p>\s*<blockquote([^>]*)>/gi,"<blockquote$1><p>");a=a.replace(/<\/blockquote>\s*<\/p>/gi,"</p></blockquote>");a=a.replace(new regexp("<p>\\s*(</?(?:"+d+")(?: [^>]*)?>)","gi"),"$1");a=a.replace(new regexp("(</?(?:"+d+")(?: [^>]*)?>)\\s*</p>","gi"),"$1");a=a.replace(/\s*\n/gi,"<br />\n");a=a.replace(new regexp("(</?(?:"+d+")[^>]*>)\\s*<br />","gi"),"$1");a=a.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi,"$1");a=a.replace(/(?:<p>|<br ?\/?>)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|<br ?\/?>)*/gi,"[caption$1[/caption]");a=a.replace(/(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)<\/p>/g,function(f,e,g){if(g.match(/<p( [^>]*)?>/)){return f}return e+"<p>"+g+"</p>"});if(c){a=a.replace(/<wp-temp-lb>/g,"\n")}if(b){a=a.replace(/<wp-temp-br([^>]*)>/g,"<br$1>")}return a},pre_wpautop:function(b){var a=this,d={o:a,data:b,unfiltered:b},c=typeof(jquery)!="undefined";if(c){jquery("body").trigger("beforeprewpautop",[d])}d.data=a._wp_nop(d.data);if(c){jquery("body").trigger("afterprewpautop",[d])}return d.data},wpautop:function(b){var a=this,d={o:a,data:b,unfiltered:b},c=typeof(jquery)!="undefined";if(c){jquery("body").trigger("beforewpautop",[d])}d.data=a._wp_autop(d.data);if(c){jquery("body").trigger("afterwpautop",[d])}return d.data}}; 

thanks help.

update: way after executing function "return_tinymce_status()" goes line of code:

  $('.switch-tmce').click(function() {    //visual editor activated   //turn off code mirror           editor.togglecodemirror('content', false);                   switcheditors.switchto(this);    }); 

maybe has "this".

i found solution this. instead of using this:

<a id="content-tmce" class="wp-switch-editor switch-tmce" onclick="return_tinymce_status();">visual</a> 

i remove onclick function using jquery result this:

<a id="content-tmce" class="wp-switch-editor switch-tmce" onclick="">visual</a> 

this using jquery:

$('.switch-tmce').attr('onclick', ''); 

then run function (return_tinymce_status) within jquery click event:

       $('.switch-tmce').click(function() {              return_tinymce_status();         }); 

error gone. problem solved. hope helps someone.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -