Note that there are some explanatory texts on larger screens.

plurals
  1. POtemplate insertion in a editor
    primarykey
    data
    text
    <h1>Describing a scenario:</h1> <p>I am going through the code mentioned below.B asically I am trying to figure out how to program so that when a user clicks on "Use Template" button , it gets inserted into an editor. Page 1: There are lot of templates present When a user clicks on the "Use Template" button on , it gets inserted into an editor that is present in the next page (Page 2).</p> <p>Please find the code snippet below for the first two templates I am going through:</p> <pre><code>&lt;div id="templatesWrap"&gt; &lt;div class="template" data-templatelocation="templateone" data-templatename="Template ONE" data-templateid="" &gt; &lt;div class="templateContainer"&gt; &lt;span&gt; &lt;a href="https://app.abc.com/pqr/core/compose/message/create?token=c1564e8e3cd11bc4t546b587jan31&amp;amp;sMessageTemplateId=templateone&amp;amp;sHubId=&amp;amp;goalComplete=200" title="Use Template"&gt; &lt;img class="thumbnail" src="templatefiles/thumbnail_010.jpg" alt="templateone"&gt; &lt;/a&gt; &lt;/span&gt; &lt;div class="templateName"&gt;Template ONE&lt;/div&gt; &lt;p&gt; &lt;a href="https://app.abc.com/pqr/core/compose/message/create?token=c1564e8e3cd11bc4t546b587jan31&amp;amp;sMessageTemplateId=templateone&amp;amp;sHubId=&amp;amp;goalComplete=200" title="Use Template" class="button secondary"&gt;Use Template&lt;/a&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="template" data-templatelocation="templatetwo" data-templatename="Template TWO" data-templateid="" &gt; &lt;div class="templateContainer"&gt; &lt;span&gt; &lt;a href="https://app.abc.com/pqr/core/compose/message/create?token=c1564e8e3cd11bc4t546b587jan31&amp;amp;sMessageTemplateId=templatetwo&amp;amp;sHubId=&amp;amp;goalComplete=200" title="Use Template"&gt; &lt;img class="thumbnail" src="templatefiles/thumbnail_011.jpg" alt="templatetwo"&gt; &lt;/a&gt; &lt;/span&gt; &lt;div class="templateName"&gt;Template TWO&lt;/div&gt; &lt;p&gt; &lt;a href="https://app.abc.com/pqr/core/compose/message/create?token=c1564e8e3cd11bc4t546b587jan31&amp;amp;sMessageTemplateId=templatetwo&amp;amp;sHubId=&amp;amp;goalComplete=200" title="Use Template" class="button secondary"&gt;Use Template&lt;/a&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>And so on ....</p> <p>How does the link <code>"https://app.abc.com/pqr/core/compose/message/create?token=c1564e8e3cd11bc4t546b587jan31&amp;amp;sMessageTemplateId=templatetwo&amp;amp;sHubId=&amp;amp;goalComplete=200"</code> is inserting the template into the editor which is located on the next page? I haven't understood the token part and lot's of ID's present in the link which I think are thereason behind inserting the template.</p> <p>Has anyone come across such link before? Please advise.</p> <p>Thanks</p> <p><strong>MORE CLARIFICATIONS:</strong></p> <p>Thanks for your answer.It did help me somewhat. I have few more questions:</p> <p>Basically, I am using TinyMCE 4.0.8 version as my editor. The templates, I am using are from here: <a href="https://github.com/mailchimp/email-blueprints/blob/master/templates/2col-1-2-leftsidebar.html" rel="nofollow">https://github.com/mailchimp/email-blueprints/blob/master/templates/2col-1-2-leftsidebar.html</a> </p> <p>Some questions based on "Tivie" answer.</p> <p>1) As you can see in the code for <code>"2col-1-2-leftsidebar.html "</code> it's not defined inside <code>&lt;div&gt;</code> tags unlike you defined it in <code>&lt;div&gt;</code> tags. Do you think that I can still use it using <code>"2col-1-2-leftsidebar.html "</code> name?</p> <p>2)I believe,for explanation purpose, you have included </p> <pre><code>`"&lt;div contenteditable="true" id="myEditor"&gt;replaced stuff&lt;/div&gt;` and &lt;button id="btn"&gt;Load TPL&lt;/button&gt; &lt;script&gt; $("#btn").click(function() { $("#myEditor").load("template.html"); }); &lt;/script&gt; </code></pre> <p>in the same page. Am I right? ( I understand you were trying to make an educated guess here, hence just asking :) )</p> <p>In my case, I have a separate page, where I have written code for buttons just like you wrote in editor.html like the following: <code>&lt;button id="btn"&gt;Load TPL&lt;/button&gt;</code>. My button is defined inside <code>&lt;div class="templateContainer"&gt;</code>. Also, my templates are defined in a separate folder. So, I will have to grab the content(HTML Template), from that folder and then insert into TinyMCE 4.08 editor. (Looks like two step process). Could you elaborate on how should I proceed here? </p> <p><strong>More Question As of Dec 27</strong></p> <p>I have modifier my code for the template as follows:</p> <pre><code> &lt;div class="templateName"&gt;Template ONE&lt;/div&gt; &lt;p&gt; &lt;a href="Here I have mentioned URL to next page where TinyMCE editor is mentioned" class="button secondary" id = "temp1"&gt;Use Template&lt;/a&gt; &lt;/p&gt; </code></pre> <p>Please note, I have added an additional id attribute for the following purpose.</p> <p>If I go by the answer mentioned in the Tivia's post, is the following correct?</p> <pre><code>&lt;script&gt; $("#temp1").click(function() { $("#sTextBody").load("FolderURL/template.html"); }); &lt;/script&gt; </code></pre> <p>My editor is defined like the following on Page 2 (Editor Page).</p> <pre><code>&lt;div class="field"&gt; &lt;textarea id="sTextBody" name="sTextBody" style="width:948px; max-width:948px; height: 70%"&gt;&lt;/textarea&gt; &lt;/div&gt; </code></pre> <p>I am confused, like, the script tag I have defined is in Page 1 where I have defined all the template related code and the Page 2(Editor) page is a different page. It's simply taking me to Editor page (Page 2) and hence not working.</p> <p>Please advise where I am wrong. Thanks</p> <p><strong>MORE QUESTIONS AS of Jan 2</strong></p> <p>The problem Iam facing is as follows. Basically, for first template , I have the following code.</p> <p><strong>Code Snippet #1</strong> where "Use "Template" button is present:</p> <pre><code>&lt;div class="templateName"&gt;Template ONE&lt;/div&gt; &lt;p&gt; &lt;a href="Here I have mentioned URL to next page where TinyMCE editor is mentioned" class="button secondary" id = "temp1"&gt;Use Template&lt;/a&gt; &lt;/p&gt; </code></pre> <p>And the function suggested in the answer is as follows:</p> <p><strong>Code Snippet #2</strong> where Editor is present:</p> <pre><code>&lt;script&gt; $("#temp1").click(function() { $("#sTextBody").load("FolderURL/template.html"); }); &lt;/script&gt; </code></pre> <p>Since, I believe I first need to reach to that page after user clicks on "Use Template" button, where the editor is located, I have defined Code Snippet #1 on Page 1 and have defined the Code Snippet #2 and <code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt;</code> as the very first two script tags in the Page 2 ( Editor Page). But still when I click on "User Template" button on Page 1, it's just letting me to next page and not loading the template into the editor. </p> <p>Am I doing something wrong here? Please advise.</p> <p>P.S. The problem I feel is somehow the click function on Page 2 is not getting activated with the <code>temp1</code> id button mentioned on Page 1.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload