3 ms·
Nice, but I question if this needs to be made into a plugin. There's a need to hook up things on the server side, and the same thing can be accomplished by wri
by csytan 17y ago
Nice, but I question if this needs to be made into a plugin. There's a need to hook up things on the server side, and the same thing can be accomplished by writing 20 lines of code.
Here's something I wrote for my translation site:
jQuery(function($){
var save_txt = '{{ _('Save') }}';
var saving_txt = '{{ _('Saving...') }}';
var saved_txt = '{{ _('Saved') }}';
function save(){
$('#save').val(saving_txt).attr('disabled', 'disabled');
$.post(window.location.pathname, {
action: 'save',
translated_text: $('#translated_text').val()
}, function(html){
$('#save').val(saved_txt);
});
}
var timer;
$('#translated_text').keyup(function(){
window.clearTimeout(timer);
$('#save').val(save_txt).attr('disabled', null);
timer = window.setTimeout(save, 5000);
})
.focus();
$('#save').click(function(){
window.clearTimeout(timer);
save();
return false;
});
});