Solved

Need 2 text areas using CKEDITOR on same page to have diffrent widths?

Posted on 2013-05-21
3
338 Views
Last Modified: 2013-05-21
Hi,
I have 2 text area on my page using CKEDITOR and need different widths for both, but it appears that both get resized to the same value and in this case using the last value specified of CKEDITOR.config.width ='300px';

Is there a way to specify a diffrent size?

Thanks.
<textarea id="content" name="content"><?php echo $content; ?></textarea>
                     
<script>

CKEDITOR.replace( 'content' );
CKEDITOR.config.width ='800px';
CKEDITOR.config.height='500px';
CKEDITOR.config.skin = 'moonocolor';

</script>                     


<textarea id="content2" name="content2"><?php echo $content2; ?></textarea>
                     
<script>

CKEDITOR.replace( 'content2' );
CKEDITOR.config.width ='300px';
CKEDITOR.config.height='500px';
CKEDITOR.config.skin = 'moonocolor';

</script>                     

Open in new window

0
Comment
Question by:sabecs
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39184219
0
 
LVL 6

Accepted Solution

by:
Robert Saylor earned 500 total points
ID: 39184241
Give this a try. I have a page "php" that uses two CKeditor boxes and both have different sizes.

   <textarea id="editor2" name="editor2" rows="10" cols="80"></textarea>
      <script type="text/javascript">
// This is a check for the CKEditor class. If not defined, the paths must be checked.
if ( typeof CKEDITOR == 'undefined' )
{
   document.write(
      '<strong><span style="color: #ff0000">Error</span>: CKEditor not found</strong>.' +
      'This sample assumes that CKEditor (not included with CKFinder) is installed in' +
      'the "/ckeditor/" path. If you have it installed in a different place, just edit' +
      'this file, changing the wrong paths in the &lt;head&gt; (line 5) and the "BasePath"' +
      'value (line 32).' ) ;
}
else
{
   var editor2 = CKEDITOR.replace( 'editor2',
      {

         width: '275px',
         height: '400px',
         toolbar :
            [
               [ 'Source','Preview' ],
               [ 'Bold', 'Italic','Underline','Strike','RemoveFormat', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink', 'Anchor' ],
               [ 'Image','Table','HorizontalRule','SpecialChar','PageBreak'],
               [ 'Styles','Format','Font','FontSize' ],
               [ 'TextColor','BGColor' ],
               [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo','-','Outdent','Indent','Blockquote','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','BidiLtr','BidiRtl' ]
            ]
      });

   editor2.setData( '<?=$sValue2?>' );
   // Just call CKFinder.SetupCKEditor and pass the CKEditor instance as the first argument.
   // The second parameter (optional), is the path for the CKFinder installation (default = "/ckfinder/").
   CKFinder.setupCKEditor( editor2, 'ckfinder/' ) ;
   // It is also possible to pass an object with selected CKFinder properties as a second argument.
   // CKFinder.SetupCKEditor( editor, { BasePath : '../../', RememberLastFolder : false } ) ;
}
      </script>

Open in new window

0
 

Author Closing Comment

by:sabecs
ID: 39184276
Thanks, that did the trick.

CKEDITOR.replace( 'content2',{ width: '275px', height: '400px' });
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now