widearea
widearea copied to clipboard
Prefilling with Localstorage-Values is messing with "real" content in forms
I have an php-based Application, where a user can create and edit posts.
When I edit any post and submit the form, the Localstorage does not get flushed automatically, which prefills the textarea marked with data-widearea= true"
whenever I edit another post. Of course, the Text coming from the localstorage is not the correct content when I edit another post/record, since it is the textareas content coming from the "last-edited" post.
Would it be possible to automatically call wideArea().clearData()
whenever a form is submitted?
I know this is kind of an individual problem, but I can Imagine a lot of people are using wideare.js in contexts, where editing Records via the same form-templates is a normal workflow…
I'm sticking to v0.2 for now… just wanted to let you know!
Best regards and thanks for your great js-libraries!
I know this is an old post, but I started using WideArea yesterday and - although I love the simplicity and functionality! - the issue Koernchen02 describes does still exist. The local storage isn't cleared on form submission, which means that the first time one calls wideArea() it takes the content of the text area and saves it into the storage, and it will persist there.
Now, the funny thing is, calling wideArea().clearData(1) doesn't only clear the local storage, but also the content of the text area! I figured that, on pressing the submit button, I could call the clearData function, but that way my $_POST array turns up an empty text area content.
The solution to this is editing the widearea.js file slightly. Line 99: currentElement.value = ''; Comment this line out. It keeps the text area content intact but will still clear the local storage (on line 100).
Hope that saves someone else a lot of searching!
Unfortunately this does not fix the issue. Any suggestions?