Solved

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

Posted on 2013-01-28
3
1,989 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

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.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
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…

738 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