<![CDATA[ Using snippet and getResources in external Javascript - MODX Community Forums]]> https://forums.modx.com/thread/?thread=100338 <![CDATA[Using snippet and getResources in external Javascript]]> https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542296
Like

alert('[[++site_name]]');



But all to be in external javascript file]]>
miomir.dancevic Jun 09, 2016, 07:21 AM https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542296
<![CDATA[Re: Using snippet and getResources in external Javascript]]> https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542322 Quote from: miomir.dancevic at Jun 09, 2016, 04:51 PM
Quote from: Bruno17 at Jun 09, 2016, 02:58 PM
For a simple alert like that, put the javascript directly into the head. Not in a file.
Or, like Susan said, create a resource with content-type of js with your javasript-code and call the url of that resource as js-file in your head.
Then you can use MODX-tags, like you did.

Yes but can i put that resource like

 <script src="MyResource.js" type="text/javascript"></script>


In some template?

Only problem i have that this way i can not use MinifyX?]]>
miomir.dancevic Jun 09, 2016, 12:23 PM https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542322
<![CDATA[Re: Using snippet and getResources in external Javascript]]> https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542320 Quote from: Bruno17 at Jun 09, 2016, 02:58 PM
For a simple alert like that, put the javascript directly into the head. Not in a file.
Or, like Susan said, create a resource with content-type of js with your javasript-code and call the url of that resource as js-file in your head.
Then you can use MODX-tags, like you did.

Yes but can i put that resource like

 <script src="MyResource.js" type="text/javascript"></script>


In some template?]]>
miomir.dancevic Jun 09, 2016, 11:51 AM https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542320
<![CDATA[Re: Using snippet and getResources in external Javascript]]> https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542313 Or, like Susan said, create a resource with content-type of js with your javasript-code and call the url of that resource as js-file in your head.
Then you can use MODX-tags, like you did.]]>
Bruno17 Jun 09, 2016, 09:58 AM https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542313
<![CDATA[Re: Using snippet and getResources in external Javascript]]> https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542308 Quote from: sottwell at Jun 09, 2016, 01:37 PM
You cannot use a snippet in Javascript. What you can do is generate Javascript with the returned values of the snippet.

Create a resource with the content type of JS. Then you can access it like any external .js file. Use your snippets in the resource as usual, formatting its output in its tpl chunks the way the Javascript expects it to be.

On the other hand, many Javascript apps work with the DOM, manipulating and using various HTML entities, which are easily generated by the same snippets with their tpl chunks for formatting the output.

Can you show me simple alert i have asked?]]>
miomir.dancevic Jun 09, 2016, 09:38 AM https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542308
<![CDATA[Re: Using snippet and getResources in external Javascript (Best Answer)]]> https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542300
Create a resource with the content type of JS. Then you can access it like any external .js file. Use your snippets in the resource as usual, formatting its output in its tpl chunks the way the Javascript expects it to be.

On the other hand, many Javascript apps work with the DOM, manipulating and using various HTML entities, which are easily generated by the same snippets with their tpl chunks for formatting the output.]]>
sottwell Jun 09, 2016, 08:37 AM https://forums.modx.com/thread/100338/using-snippet-and-getresources-in-external-javascript#dis-post-542300