How to keep state of custom field in panel after page reload

Hey,

a while ago I made the list plugin (here a github link) that allows you to create simple list entries and to sort them via drag & drop:

list field demo

I would like to prevent this field from resetting to its stored state after the page is reloaded. This includes added or removed list entries and their sorting. All is lost when the page reloads. The big problem is that such a reload is also triggered after uploading a new file to the page or sorting a structure field on the page, i.e. all my edits on my list field could be lost only because I edited another field before hitting the save button.

I took a look at how the structure field handles this but, to be honest, couldn’t get my head around the mechanisms behind it. I just found my self lost the deep, deep core of the panel…

Can you guys give me some insights on how the temporary changes are stored parallel to the data from the .txt file?

Thanks a lot!

1 Like

Can’t help you, but experience the same issues with structure fields and snippet fields;

I change them (structure or snippet), Kirby does some AJAX-voodoo-woodoo and all my changes are reset, without hitting the save button.

I guess you can store some shizzle in the localStorage() and read it like an array() afterwards - but it’s a pain in the *ss… :slight_smile:


BTW. I used your list-field for about three sites - and it rocks, thx!

Does this help?

No, not really. Though your issue also had to do with the reload mechanisms inside the panel, it is some different kind of a problem.

Anyway, thanks for the idea.

lol funny I just fixed this for you plugin a couple of days ago…

In your js you can do this, on update and all your other functions :

$(element).closest('form').trigger('keep');

oh by the way, is there any chance your builder plugin will accept nesting in the near future ?
Keep cool /

Fred

Thanks H-i! This works. @bastianallgeier it would be great if the docs would cover this. It is really a bummer if the content of custom fields is lost before saving.

oh by the way, is there any chance your builder plugin will accept nesting in the near future ?

I am still hoping that bastian comes up with a solution to have nested structures so that i can adapt his solution for the builder field. For the moment, I am not working on an own solution.