Solved

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

Posted on 2013-01-28
3
1,896 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now