mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-16 03:03:14 +00:00
Improve JS behavior when editing slug (fixes #132)
This commit is contained in:
parent
0b89334eba
commit
c1ac89ceb7
1 changed files with 14 additions and 2 deletions
|
|
@ -261,8 +261,20 @@ function initSlugAutoPopulate(){
|
|||
}
|
||||
|
||||
function initSlugCleaning(){
|
||||
$('#id_slug').on('keyup blur', function(){
|
||||
$(this).val(cleanForSlug($(this).val()));
|
||||
$('#id_slug').on({
|
||||
'blur': function(){
|
||||
$(this).val(cleanForSlug($(this).val()));
|
||||
},
|
||||
'keyup': function(event){
|
||||
var keyCode = ('which' in event) ? event.which : event.keyCode;
|
||||
if (
|
||||
(keyCode != 32) && // not spacebar
|
||||
(keyCode != 8) && // not backspace
|
||||
(keyCode != 46) && // not delete
|
||||
((keyCode < 40) ) // non-character
|
||||
) return ;
|
||||
$(this).val(cleanForSlug($(this).val()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue