load later
This commit is contained in:
parent
a3f32323b1
commit
99a37b946a
1 changed files with 19 additions and 17 deletions
|
@ -1,18 +1,20 @@
|
|||
django.jQuery(function() {
|
||||
django.jQuery('textarea[maxlength]').each(function(i, textarea) {
|
||||
var t = django.jQuery(textarea),
|
||||
count = t.parent().find('.maxlength-count')
|
||||
if (count.length == 0) {
|
||||
count = django.jQuery('<div>', {'class': 'maxlength-count'} ).insertAfter(t)
|
||||
t.on({
|
||||
keydown: update,
|
||||
change: update,
|
||||
drop: update,
|
||||
})
|
||||
}
|
||||
function update() {
|
||||
var max = Math.round(t.attr('maxlength')), left = max - t.val().length
|
||||
count.html(left + ' characters left. (max: ' + max + ')')
|
||||
}
|
||||
window.addEventListener("load", function() {
|
||||
django.jQuery(function() {
|
||||
django.jQuery('textarea[maxlength]').each(function(i, textarea) {
|
||||
var t = django.jQuery(textarea),
|
||||
count = t.parent().find('.maxlength-count')
|
||||
if (count.length == 0) {
|
||||
count = django.jQuery('<div>', {'class': 'maxlength-count'} ).insertAfter(t)
|
||||
t.on({
|
||||
keydown: update,
|
||||
change: update,
|
||||
drop: update,
|
||||
})
|
||||
}
|
||||
function update() {
|
||||
var max = Math.round(t.attr('maxlength')), left = max - t.val().length
|
||||
count.html(left + ' characters left. (max: ' + max + ')')
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue