$(document).ready(function () {
$("#txtRfq").attr('maxlength', '9');
$("#txtRfq").caretToEnd(); // This is to set caret at end on page load
/* The below is to set caret at end on clicking the text box */
$("#txtRfq").on("click", function () {
$("#txtRfq").caretToEnd();
});
/*The below is to set caret at end when the text box gets focus through tabbing */
$("#txtRfq").on("focus", function (e) {
$(this).delay(13).caretToEnd();
});
});
var viewModel = kendo.observable({
poId: null,
rfq: "RFQ"
});
kendo.bind($("#view"), viewModel);
/* The below is the contents of the jquery-caret.js library. I have added the full code here because I wasn't able to include the src. You wouldn't need this */ (function ($) {
// Behind the scenes method deals with browser
// idiosyncrasies and such
$.caretTo = function (el, index) {
if (el.createTextRange) {
var range = el.createTextRange();
range.move("character", index);
range.select();
} else if (el.selectionStart != null) {
el.focus();
el.setSelectionRange(index, index);
}
};
// Another behind the scenes that collects the
// current caret position for an element
// TODO: Get working with Opera
$.caretPos = function (el) {
if ("selection" in document) {
var range = el.createTextRange();
try {
range.setEndPoint("EndToStart", document.selection.createRange());
} catch (e) {
// Catch IE failure here, return 0 like
// other browsers
return 0;
}
return range.text.length;
} else if (el.selectionStart != null) {
return el.selectionStart;
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.