[英]How do I get keystoneJS to run a function once a specific model has been updated?
[英]Android App - Run JavaScript function once, then not again until the app has been updated
我正在使用JavaScript制作Android PhoneGap应用。
该应用程序从本地文本文件加载数据并将其存储在本地存储中,然后从本地存储中加载数据。
当我想更新文本文件中的数据并让应用再次将数据重新加载到本地存储中时,就会出现问题。 我无法一次加载文本文件,然后再也无法加载。 每次应用启动时,它将再次加载文本文件,直到我执行另一个将localStorage.update = 0设置的更新为止。
这是我尝试过的代码,但得到了上述结果。
localStorage.update = 1; //tell the app to update
//but this will run each time the app is opened
if(localStorage.update == 1) {
localStorage["StoredData"] = ""; //text file data is stored in [StoredData]
//Proceed to load the text file into storage
localStorage.update = 0;
}
谢谢。
证明以下代码有效:
if(localStorage.update == 1) { // change this value everytime you want to reload the file
localStorage["StoredData"] = ""; //text file data is stored in [StoredData]
//Proceed to load the text file into storage
localStorage.update = 1; //set this to the same as the if statement
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.