Open GoogleCodeExporter opened 8 years ago
It appears when the formatted string is put back into the field, the cursor
gets reset to the end of the line. I experimented with a plugin called jCaret
to determine the cursor position before the formatting and then reset it once
the format was applied and it seemed to work. This is not tested very
thoroughly but could give someone a place to start to fix this bug (if the bug
is worth fixing). I inserted some code (and loaded the jcaret plugin in my
page) around line 134:
// set destination
var startPos = $(this).caret().start; // position of the cursor when the user
typed something
var startLength = $(this).val().length; //length of the input before we applied
the formatting
$destination[$destination.is('input, select, textarea') ? 'val' :
'html'](money);
// if we havent inserted any new formatting, set the cursor back to what it was
if (startLength == money.length)
{
$(this).caret({start:startPos, end:startPos});
}
else // if we have, adjust the cursor accordingly
{
$(this).caret({start:startPos +(money.length - startLength),end:startPos +(money.length - startLength) });
}
Original comment by andrew.l...@gmail.com
on 2 Dec 2010 at 4:09
Original issue reported on code.google.com by
andrew.l...@gmail.com
on 2 Dec 2010 at 1:35