Align the selected text in radeditor through cusotmise function.

2 posts, 0 answers
  1. bibhudatta Mangaraj
    bibhudatta Mangaraj avatar
    8 posts
    Member since:
    Jan 2010

    Posted 21 Jan 2010 Link to this post

    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;

    }

     

  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 26 Jan 2010 Link to this post

    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.
  3. DevCraft banner
Back to Top