<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged requirejs</title>
<link>https://overflow.efficy.io/?qa=tag/requirejs</link>
<description>Powered by Question2Answer</description>
<item>
<title>Guest page &amp; requirejs : Yes we can!</title>
<link>https://overflow.efficy.io/?qa=6181/guest-page-requirejs-yes-we-can</link>
<description>&lt;p&gt;I know, I know, I know: Guest pages went to the dark side of the force! But since I'm as old as Methuselah, I already had to work on them and still have to, for legacy reasons.&lt;/p&gt;

&lt;p&gt;First I have to thank Stéphane &amp;amp; Kristof, our gurus, who opened the Red Sea waters to let me reach the Holy Land. &lt;/p&gt;

&lt;p&gt;The first step to activate requirejs framework from a guest page is to call a macro like this one:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;DialogScripts {[
  &amp;lt;%UseScript('js/config/require.config.js', fixedpath=T, data-custombase='%%GetFileBase(short=T)')%&amp;gt;
  &amp;lt;%Evaluate(&quot;%%Macro('RequireConfigCustom')&quot;)%&amp;gt;
  &amp;lt;%UseScript('../../../../lib/js/vendor/require.js', fixedpath=T, data-main='%%Macro(&quot;MainJsModule&quot;)', data-custom-main='%%Macro(&quot;MainJsModuleCustom&quot;)')%&amp;gt;
]}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The second one is to copy the standard &lt;code&gt;efficy/js/config/require.config.js&lt;/code&gt; file in your &lt;code&gt;guest/myGuest/js/config&lt;/code&gt; folder. A few drops of Holy water on this file will then suffice to perform the miracle :&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;baseUrl: '../guest/myGuest/js',
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Since your custom &lt;code&gt;require.config.js&lt;/code&gt; is one level deeper than the efficy one, you have to add one &lt;code&gt;../&lt;/code&gt; to all relative paths:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;'domReady':               '../../lib/js/vendor/require.domReady',
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;becomes&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;'domReady':             '../../../lib/js/vendor/require.domReady',
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Add this &lt;code&gt;../&lt;/code&gt; to all standard modules relative paths.&lt;/p&gt;

&lt;p&gt;And at the end of the file :&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if (tagC) {
  attrC = tagC.getAttribute(attrC).replace(/([^\/]*)\/$/, '$1'); // remove trailing slash;
  if (attrC) require.paths.custom = '../' + attrC + '/js/';
}
if (tagD) {
  attrD = tagD.getAttribute(attrD).replace(/([^\/]*)\/$/, '$1'); // remove trailing slash;
  if (attrD &amp;amp;&amp;amp; attrD !== '..') require.paths.dealer = '../' + attrD + '/js/';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;becomes&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if (tagC) {
  attrC = tagC.getAttribute(attrC).replace(/([^\/]*)\/$/, '$1'); // remove trailing slash;
if (attrC)
  require.paths.custom = '../../' + attrC + '/js/';
}
if (tagD) {
  attrD = tagD.getAttribute(attrD).replace(/([^\/]*)\/$/, '$1'); // remove trailing slash;
if (attrD &amp;amp;&amp;amp; attrD !== '..')
  require.paths.dealer = '../../' + attrD + '/js/';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can now use the requirejs well known syntax from your page :&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;requirejs(
  ['standardModule', 'custom/misc/customModule'],
  function(StandardModule, CustomModule) {
     ...
  }
);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Meditate on this Psalm III of Chapter II of the Gospel according to Saint Peter and think about it the next time you'll have to work on a guest page.&lt;/p&gt;

&lt;p&gt;Amen!&lt;/p&gt;
</description>
<category>Guest</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=6181/guest-page-requirejs-yes-we-can</guid>
<pubDate>Fri, 18 Jun 2021 11:48:26 +0000</pubDate>
</item>
<item>
<title>Add a &quot;AddAction&quot; button to dashboard Widget</title>
<link>https://overflow.efficy.io/?qa=1256/add-a-addaction-button-to-dashboard-widget</link>
<description>&lt;p&gt;How do we need to approach the addition of an &quot;Add Action&quot; button in the Efficy Dashboard in for example the &quot;Today Tasks&quot; Widget?&lt;/p&gt;

&lt;p&gt;I've been trying several ways to achieve this, but I can't get the button to work.&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=1256/add-a-addaction-button-to-dashboard-widget</guid>
<pubDate>Wed, 20 Jan 2016 19:34:20 +0000</pubDate>
</item>
<item>
<title>requirejs error in custom.js</title>
<link>https://overflow.efficy.io/?qa=1055/requirejs-error-in-custom-js</link>
<description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I'm trying to use &quot;jquery&quot; and &quot;format&quot; in custom.js as the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function CreateRelation(Bookmark, MainEntity, MainKey, Entity, Key) {   
    requirejs(['jquery', 'utils/format', 'utils/utils'], 
    function ($, format, Utils) {   
        if ((MainEntity == 'Proj' || MainEntity == 'Oppo') &amp;amp;&amp;amp; Entity == 'Prod') {       
            var sameBrand = '0';        
            var ExtraParams = &quot;&amp;amp;MainKey=&quot; + MainKey +&quot;&amp;amp;ProdKey=&quot;  Key+&quot;&amp;amp;MainEntity=&quot;+MainEntity;        
            $.ajax({url: format(&quot;dialog?_macrofile=MacroAjax&amp;amp;_macro=RunScript&amp;amp;File=$0&amp;amp;Func=$1&quot;, &quot;serverscripts/common.js&quot;, &quot;sameBrandEntProd&quot;),             
            data: ExtraParams   
            }).done(function (html) {
                sameBrand = html;
            });         
            if (sameBrand == '1') 
                EditRelation(&quot;edit/relation.htm&quot;, MainEntity, MainKey, Entity, Key);        
            else 
                alert('You can not link this product because it does not have the right brand.');   
        } 
    });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But i'm getting this error:&lt;br&gt;
&lt;img src=&quot;https://overflow.efficy.com/?qa=blob&amp;amp;qa_blobid=5015690060356010265&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;

&lt;p&gt;Am i missing some thing? please let me know your suggestion and advises.&lt;br&gt;
Best Regards.&lt;/p&gt;
</description>
<category>Efficy Partners</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=1055/requirejs-error-in-custom-js</guid>
<pubDate>Wed, 30 Dec 2015 09:50:29 +0000</pubDate>
</item>
</channel>
</rss>