Background:
I’m getting data into my data table from models/data.js where a populate a variable.
Being lazy, I wrote a script that re-writes the file when a user adds data by a form, removes lines from the data table etc.
Implementation:
define([
“models/data”,
“views/forms/add_data”], function(x,add_data) …
Now all my changes are shown in the file models/data.js, but any time I re-enter on the page with the data table, I get old data. This is probably because of caching. Is there any way to force webix re-read the file?
Kate
What models/data file contains? Is it a hardcoded JS data object , or an instance of webix.DataCollection?
In common case, the data will be refreshed only when the page is refreshed in a browser ( js code load data only once and will not update it automatically, while you are changing inner views in the SPA )
If you are using data collection, you can use data.clearAll(); data.load("/data.json");
to refetch the data from a server-side
Hi Maksim,
it’s a JSON file that gets changed by an external program.
The page object is a datatable. I changed the attribute to URL now, and the data file format to pure JSON. The data gets loaded correctly the first time I enter the page.
Then I call (by a button in the interface) a script to add data in the file. I move to another tab/sub page in the same webix app. When I re-enter the datatable’s page, I do not see my changes in the datatable. Checking Apache’s access log, I see that the URL was not accessed again.
To avoid misunderstandings, here’s a bit of source:
view:“datatable”,
select:true,
margin:10,
id:“myData”,
resizeColumn:true,
columns:[
{id:“a”…}, …
]
url: “models/mydata.json”
Kate
When I re-enter the datatable’s page
If datatable is not recreated, you need to call
$$("myData").clearAll();
$$("myData").load("models/mydata.json");
to re-read data from an external file.