Solved

Using cleditor - how to set focus at end of textarea?

Posted on 2013-01-28
3
1,930 Views
Last Modified: 2013-02-03
I'm happily using cleditor with my jquery code and have read the available docs: (http://premiumsoftware.net/cleditor/docs/GettingStarted.html#usage) but I am still not able to fix one problem:

I have a textarea (id="input") which has cleditor applied to it and then gets the focus, using:

$('#tsTable').on('click', '.edit', function() {
  //other code
  //other code
  $('#input').cleditor()[0].focus();
}):

Open in new window

This works successfully, but the cursor in the textarea is at the beginning of the loaded content.  How do I get the cursor to be at the end of the loaded textarea text?
0
Comment
Question by:ShanghaiD
  • 2
3 Comments
 
LVL 3

Expert Comment

by:Khilu
ID: 38830006
0
 

Accepted Solution

by:
ShanghaiD earned 0 total points
ID: 38834125
Thanks, but these did not work (because of the way cleditor works -- it hides the original textarea and creates its own iframe and related content).

After further searching, I finally found the "cleditor" specific solution which invovles using cleditor to insert the required text and then setting the focus.

The sytax which works is as follows (if anyone else has the same problem):

$('#input').cleditor({updateTextArea:function (){}})[0].execCommand('inserthtml', theHTML, null, null).focus();

where theHTML is the html to be displayed.

Here is the source for the solution (for further background understanding): http://stackoverflow.com/questions/5093076/cleditor-dynamic-adding-text
0
 

Author Closing Comment

by:ShanghaiD
ID: 38848339
The solution I found came from another source.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

770 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