Reputation: 3820
i'm trying to get width and height of tinymce editor.
i'm trying to set width and height of textarea fit with rich text editor.
tried with jquery, but default it returns width=100px only :|
setup : function(ed) {
// Add a custom button
ed.addButton('bbcodemode', {
title : 'View BBcode source',
image : '{link}/tiny_mce/themes/advanced/img/bbcodemode.gif',
onclick : function() {
$.ajax({
type: "POST",
url: "{link}/htmltobbcode/",
data: "ctn="+encodeURIComponent(tinyMCE.activeEditor.getContent()),
success: function(msg){
$('#post_content').val(msg);
//tinyMCE.activeEditor.setContent(msg);
}
});
alert($('#post_content_ifr').width());
$('#post_content').css("width",$('#post_content_ifr').width());
$('#post_content').css("height",$('#post_content_ifr').height());
// Add you own code to execute something on click
tinyMCE.execCommand('mceToggleEditor',false,'post_content');
}
});
}
Upvotes: 3
Views: 5111
Reputation: 50832
If the height and width of your editor have been set in the tinymce configuration you are able to get those settings from there using
tinymce.get('post_content').getParam('height');
and
tinymce.get('post_content').getParam('width');
Upvotes: 2
Reputation: 6619
Are you sure you execute the function after it has initalied? Couse this works for me:
$("#content_ifr").width()
I get 682 when I execute the above code in the console on this page: http://www.tinymce.com/tryit/jquery_version.php
Upvotes: 0