locked
Adding Javascript Rich Text editor to CRM 2011 RRS feed

  • Question

  • Hi All,

    I am trying to use YUI Simple Text editor on a textarea. I am using following code for same

    function createEditor(nameOfField){
    	$("<link/>", {
    	   rel: "stylesheet",
    	   type: "text/css",
    	   href: "https://ajax.googleapis.com/ajax/libs/yui/2.9.0/build/fonts/fonts-min.css"
    	}).appendTo("head");
    	$("<link/>", {
    	   rel: "stylesheet",
    	   type: "text/css",
    	   href: "https://ajax.googleapis.com/ajax/libs/yui/2.9.0/build/editor/assets/skins/sam/simpleeditor.css"
    	}).appendTo("head");
    	$.getScript('https://ajax.googleapis.com/ajax/libs/yui/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js', function(){
    		$.getScript('https://ajax.googleapis.com/ajax/libs/yui/2.9.0/build/element/element-min.js', function(){
    			$.getScript('https://ajax.googleapis.com/ajax/libs/yui/2.9.0/build/container/container_core-min.js', function() {
    				$.getScript('https://ajax.googleapis.com/ajax/libs/yui/2.9.0/build/editor/simpleeditor-min.js', function (){
    					onReadyOfDocument();
    				});
    			});
    		});
    	});
    
    	function onReadyOfDocument() {
    		$('#'+nameOfField).parent().addClass('yui-skin-sam');
    		var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event;
    
    		var myConfig = {
    			height: '100%',
    			width: '100%',
    			dompath: true,
    			focusAtStart: true
    		};
    
    		var myEditor = new YAHOO.widget.SimpleEditor(nameOfField, myConfig);
    		myEditor.render();
    	}
    }
    createEditor('TextareaIDgoesHere');

    The above code works fine if I add it to a HTML with a textbox in it and Jquery-min included in the page.  But when I add it to a CRM 2011 page it executes without any problem but then Rich text editor is never displayed.

    I am not sure if I am missing something here?


    -Devashish
    http://thecrmworld.wordpress.com
    http://ebizartisans.com

    Wednesday, April 18, 2012 11:57 AM

All replies

  • Do you have your jQuery web resource listed before the web resource containing your script? I tested your code on a multi-line text field on it worked as I expected. You might also look to see if any files you are pulling down are getting blocked. Fiddler or the IE Developer Toolbar (F12 - Network) will help you see the traffic and if files aren't getting downloaded. 

    Jason Lattimer

    Wednesday, April 18, 2012 12:57 PM
    Moderator
  • Hi,

    Thanks for a quick answer. I have seen that the css and Js both getting loaded without any problem I even added a delay to make sure things get loaded and I am able to check see that they are loaded using developer tool (F12). By the way are you able to see the rich text editor on CRM form (I am talking about CRM form not a web resource in CRM)?

    I am able to see the rich text editor on a web resource but cannot get it working on CRM 2011 form  with a multi line text area. 

    Thanks

    Dev


    -Devashish
    http://thecrmworld.wordpress.com
    http://ebizartisans.com

    Thursday, April 19, 2012 4:49 AM
  • Yes - I did have it loaded up on the actual CRM form. One other thing, are you viewing the form on the CRM server itself or from a client? I ran into a situation doing a different implementation of a WYSIWYG editor where on the CRM server itself it did not function properly (might be IE security settings causing issues?)  but it worked fine from a client browser. 

    Jason Lattimer

    Thursday, April 19, 2012 2:46 PM
    Moderator
  • Hello Guys,

    Its a very old post now, but i need similar kind of functionality in CRM 2013, I tried this script in CRM 2011 but its not showing any editor.

    I followed the below step:

    1. Created a jscript webresource with above script ,without the last line where the function is called.

    2. Added the jquery script

    3.Called the function on onload and on change event of the text area field.

    any help is highly appreciated.

    thanks alot,

    Regards

    Abhi

    Friday, December 20, 2013 6:48 PM