GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.94k stars 393 forks source link

Problems extracting DOM to submit #565

Open FuXual opened 4 years ago

FuXual commented 4 years ago

This is no bug report or something. I have a problem with the regions object. Im trying to instead of using an ajax request to send FormData(), to apply the form as hidden input fields before making a submit of the page. My sites flow is to not use ajax for most things, but instead submit the page with data. This is for e.g. tracking, SEO, security (by checking that its not the wrong user doing the request) and so on and so on.

When trying to log out what's in the regions object i can't really get any usefull values/data from there. Please understand that JS is not my language by birth :)

If i understand it right, the data saved by the ajax call is the clean variant of the HTML? right? Not with all the css classes that ContentTools uses to make its magic. Like images should not be saved as <div styel="background jada jada../> but as img-tag and such. I have tried now for more than a day to extract something useful to send to my backend, but nothing yet. Please help me out here :)

Thanks a lot in advance!

anthonyjb commented 4 years ago

Hi @FuXual can you send me an example of your JS that's being used to gather the html to submit to your server. Also have you tried implementing this code from the tutorial? - http://getcontenttools.com/tutorials/saving-strategies#sending-save-requests-to-the-server-with-ajax

FuXual commented 4 years ago

Thank you for your answer Anthony! And thank you very much for this great application! Yes, i have read it, but I instead solved it by making my own DOM parser and converter.

This is because that my project im building is a bit different in many ways, and im just using ContentTools as an engine (in some way). Im bypassing most of the functionality and triggers events very differently etc.

I then utilize htmlLawed like functionality (written by me) in the backend to parse it again for other reasons (mostly security reasons). I also have my own version control software in the backend (which is the main project)

Thanks again alot for this piece of software :)