?
Solved

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

Posted on 2013-01-28
3
Medium Priority
?
2,059 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

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

752 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