GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.38k stars 4.06k forks source link

How to change some var by a modal in GRAPEJS #234

Closed blackbirdzzz closed 7 years ago

blackbirdzzz commented 7 years ago

Hi i wanted to know how in the API grapejs can i change some variable in my builder space exemple i place 3 text with some different name like : VAR1 VAR2 VAR3 and i wanted to change those var by the value i submit in my modal : (see picture) how to it on code it is possible to get some (sample of code) or the best idea to do IT thanks again !

https://www.noelshack.com/2017-33-3-1502874762-capture-d-ecran-2017-08-16-a-11-12-22.png https://www.noelshack.com/2017-33-3-1502874771-capture-d-ecran-2017-08-16-a-11-08-21.png https://www.noelshack.com/2017-33-3-1502874783-capture-d-ecran-2017-08-16-a-11-08-35.png

artf commented 7 years ago

Well, usually variables inside newsletter templates are replaced by the server, but if you want to replace something before submitting it, you might want to create just come custom function

<div id="sbm">Submit<div>
<script>
...
$('sbm').on('click', function() {
 var finalHtml = editor.getHtml();
 finalHtml = finalHtml.replace('{{ VAR }}', 'value');
 $.ajax({
  ...
  data: {html: finalHtml}
 })
})
</script>
lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.