Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Silverlight ERP To Angularjs,HTML5 3 55
need help with share buttons 11 65
SVG and IE11 2 15
Calculating percentage 2 25
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

679 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