Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript auto save input

var saveTimeoutId;

document.addEventListener("DOMContentLoaded", () => {
  // Get the element(s) you want to autosave
  let area = document.getElementById('area');
  
  // use keyup over keypress so that backspaces will register
  area.addEventListener('keyup', () =>{
    
    // clear save timeout as the user is editing
    if (saveTimeoutId) window.clearTimeout(saveTimeoutId);
    
    // Store the timeout id again
    saveTimeoutId = window.setTimeout(() =>{
      ...
      // Code for saving here
      ...
    }, 1000); // Configure timeout period to preference
  });
  
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: check all after click first checkbox jquery 
Javascript :: replace - with space 
Javascript :: efault loader is not compatible with `next export`. 
Javascript :: ecampus kgisl, kgcas, kgisl 
Javascript :: router class in backbone 
Javascript :: Não é possível chamar Veiculo.create(). O método create não foi configurado. O PersistedModel não foi conectado corretamente a uma DataSource! 
Javascript :: router link active in vue.js 
Javascript :: regular expression javascript with domain validation 
Javascript :: js random int 
Javascript :: js set attribute 
Javascript :: getstaticpaths with redux 
Javascript :: javascript get date start of today 
Javascript :: javascript change data attribute value 
Javascript :: create link and click javascript 
Javascript :: javascript reverse string without reverse method 
Javascript :: Fancybox 2 popup show no of images counter 
Javascript :: refresh page js 
Javascript :: scroll to bottom 
Javascript :: js for object 
Javascript :: javascript run function once 
Javascript :: regex to check if string contains special characters javascript 
Javascript :: js cant find element 
Javascript :: how to get orientation in js 
Javascript :: get meta tag value from url javascript 
Javascript :: javascript stringify an object 
Javascript :: how to flatten array with reduce in javascript 
Javascript :: ng generate component in folder 
Javascript :: go to nextelementsibling javascript 
Javascript :: To set the text of button using Jquery 
Javascript :: js how to hide an image 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =