This is a migrated thread and some comments may be shown as answers.

Align the selected text in radeditor through cusotmise function.

1 Answer 40 Views
Code Templates
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
bibhudatta Mangaraj
Top achievements
Rank 1
bibhudatta Mangaraj asked on 21 Jan 2010, 12:00 PM
Hi i am using the below code for checking the selected paragraph and do the alignment,But i couldn't able to achive the solution.
Some how i need to clear the innerHtml and applay alignment and replace it back.Pls help me out.

function

 

SetFormatting(obj)

 

{

 

var editor =$find("RadEditor1");

 

 

var docObject =$(editor._contentArea);

 

 

var elem = editor.getSelectedElement()

 

 

if (elem.tagName == "P")

 

{

 

 

var paraId=$(docObject).find("p");

 

$(docObject).find(

"p").click(function(e)

 

{

 

if($(docObject).find("p#IndentParaId")[0]!=null)

 

$(docObject).find(

"p#IndentParaId")[0].id = "";

 

 

this.id = "IndentParaId";

 

currentParaId =

this.id;

 

});

editor.selectElement(elem);

 

// argument = elem;

 

}

 

else

 

{

 

var content = editor.getSelectionHtml();

 

 

// var link = editor.get_document().createElement("p");

 

 

var link = editor.get_document();

 

 

//editor.get_document().createElement("p").innerHTML=content;

 

link.innerHTML= content;

 

// link.setHtml=

 

 

if (link.tagName != "")

 

{

link.innerHTML = content;

link.id=

"IndentParaId"

 

currentParaId=link.id;

editor.Document.execCommand(

"Delete", null, false);

 

 

// link.style.textAlign=args;

 

 

// argument = link;

 

 

// $(link).find("P").context.style.textAlign=obj;

 

$(link)[0].style.textAlign =obj;

}

 

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 26 Jan 2010, 11:48 AM
Hi Bibhudatta,

After examining the provided code I noticed the following problems:
  • editor.Document.execCommand("Delete", null, false);
    This is a RadEditor Classic method - should be editor.get_document().execCommand("Delete", null, false)
  • var link = editor.get_document();
    link.innerHTML = content;
    editor.get_document() returns the document object of the <iframe> used for the content area and it has no innerHTML property - should be link.body.innerHTML = content;

I am not really sure that I can fully understand your question. Could you please provide detailed information about your specific scenario and what errors do you get after execution of this function?

Best wishes,

Dobromir
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Code Templates
Asked by
bibhudatta Mangaraj
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or