[Beginner] Expand WYSIWYG Editor Automatically


(Nic Hubbard) #1

I have always hated how the WYSIWYG Editor does not expand by itself, so I added a click event to ours so that they will always expend when the page is opened.


Requirements: jQuery



The WYSIWYG editor uses an onclick event which is bound to a div. So, we first need to wrap the keywords that print editors, with another div. So, for example, if we have a news item Asset Builder, and we want both the summary and body editors to expand, we would do the following in the Create Layout Form:


    
%details-F_summary%
%details-F_body%


Wrapping our keywords in divs ensures that we can more specifically target the element we want to simulate the click on.

Now, we add a little jQuery to our page to simulate a click inside each of our divs:

      $(document).ready(function() {
    	$('#editor1 div, #editor2 div').trigger('click');
      });


Now our WYSIWYG Editors expend when we load the page!

(Duncan Robertson) #2

That was simple. I think we just hacked the code and put it in raw. Awesome :slight_smile:


(sport taip) #3

Very useful tip!

Trying this with a standard page but no idea what the keyword replacement is. "F_body" only works with news assets. Can anyone help?

<div id="editor2">%details-F_body%</div>

(Mark Brydon) #4

[quote]Very useful tip!
Trying this with a standard page but no idea what the keyword replacement is. "F_body" only works with news assets. Can anyone help?



<div id="editor2">%details-F_body%</div>[/quote]

If you are using an Asset Builder to create a Standard Page, the bodycopies will not be created until completing the Asset Builder process.

Once it is created you can navigate to the Simple Edit view of the created asset - easily accomplished from the create URL after the Asset Builder - and use the %__custom-contents% keyword in your Layout to edit the page contents.



Edit: Dash, not underscore between "custom" and "contents"