Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
64
rated 0 times [  71] [ 7]  / answers: 1 / hits: 5970  / 10 Years ago, wed, may 21, 2014, 12:00:00

The Situation



I have to create a web-application that allows me to, starting from a blank page, insert new html, images and so on, and allows to edit it with features like: resize, positioning and so on.



To figure out what I'm talking about, see: https://www.scrollkit.com in its editor section.



My Question



How should I save the new html I create, with the CSS bound to it, to my server?



Should I use a JSON structure in which I put all my elements with something like:



 { 
attributes: ,
tag: div,
html: some-html,
..
}


Or should I save the entire (maybe compiled?) html page to the file-system?



Thanks in advance to all.


More From » jquery

 Answers
3

I see this as an architecture question more then a code question, especially since the asker didn't specify what server side technology they are using or are comfortable with.



Here is how I would design this:



I'd have a div where all the content would go inside. I'd optionally have a style element (with an id) that all my custom css would be written into. I'd simply save the contents of the div and css style to the server, using ajax, when various things happened (user hit save button, perhaps auto-save every so many minutes, etc), and reload it when needed (on page load, reset button, maybe undo, etc.).



Hopefully, I'd be able to build all my insert/resize/position code to work just off of html. If I needed to, I'd put data- elements on my html to store information I needed to make all my manipulation work. I'd strongly hesitate to have a duplicate JavaScript structure in memory for all my elements, because it seems that nightmares could happen if they get out of sync. However, if you have to do so, I'd also save that to the server and reload it. I'd find a way to rebuild either the structure or the data- attributes if they don't exist.



That's a good enough start, I think. Feel free to ask questions.


[#45150] Tuesday, May 20, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
santiago

Total Points: 375
Total Questions: 106
Total Answers: 97

Location: Argentina
Member since Thu, Mar 18, 2021
3 Years ago
;