grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

How to change some var by a modal in GRAPEJS

Open blackbirdzzz opened this issue 9 years ago • 2 comments

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

blackbirdzzz avatar Aug 16 '17 09:08 blackbirdzzz

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>

artf avatar Aug 16 '17 12:08 artf

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.

lock[bot] avatar Sep 18 '19 14:09 lock[bot]