Maintain cursor position while cleaning up the folder name value (fixes #144)

This commit is contained in:
Djamil Legato
2015-09-07 13:06:07 -07:00
parent 8688eb8429
commit ae29c38f19

View File

@@ -163,8 +163,14 @@ $(function(){
$('input[name="folder"]').on('input', function(e){ $('input[name="folder"]').on('input', function(e){
var start = this.selectionStart,
end = this.selectionEnd;
value = $(this).val().toLowerCase().replace(/\s/g, '-').replace(/[^a-z0-9_\-]/g, ''); value = $(this).val().toLowerCase().replace(/\s/g, '-').replace(/[^a-z0-9_\-]/g, '');
$(this).val(value); $(this).val(value);
// restore cursor position
this.setSelectionRange(start, end);
}); });
childrenToggles.on('click', function () { childrenToggles.on('click', function () {