I'm trying to get the last position of the cursor when the user clicks outside of the RadTextbox, but I'm not quite sure it's working how I was hoping. I added an OnBlur client event in the mark-up:
Next I have my JavaScript:
My goal is to trap the last cursor position and save it in a hidden field on the page for use w/ drag'n'drop functionality from a RadListBox to the RadTextBox. It seems like it's working correctly except the numbers come out really random. For instance, I put 10 characters in the textbox and then put the cursor in the middle and clicked out of the textbox, but the number returned by get_caretPosition() was 80? Doesn't make sense to me... any ideas or suggestions? Is what I'm doing possible or has the cursor position been lost by the time the OnBlur event is fired?
<telerik:RadTextBox ID="rtxtTemplateContent" Runat="server" Height="100px" TextMode="MultiLine" Width="250px"> |
<ClientEvents OnBlur="setCursorPosition" /> |
</telerik:RadTextBox> |
Next I have my JavaScript:
function setCursorPosition(sender) { |
var cursorPosition = sender.get_caretPosition() |
document.getElementById("hdnCursorPosition").value = cursorPosition; |
} |
My goal is to trap the last cursor position and save it in a hidden field on the page for use w/ drag'n'drop functionality from a RadListBox to the RadTextBox. It seems like it's working correctly except the numbers come out really random. For instance, I put 10 characters in the textbox and then put the cursor in the middle and clicked out of the textbox, but the number returned by get_caretPosition() was 80? Doesn't make sense to me... any ideas or suggestions? Is what I'm doing possible or has the cursor position been lost by the time the OnBlur event is fired?