javascript - Sourcing Global Function from an Anonymous Function that Returns in Adobe DTM -


the below code snippets not actual code, there explain issue. please don't concentrate on actual functionality. i'm working adobe dtm. have no idea how anonymous function returns value (as data element source global function? if have normal anonymous function within data element, works fine. if anonymous function returns, doesn't work? there way work? example:

//global function function _myglobalfunct(str){ return (str); } 

the following code of anonymous function within data element calls global function , works expected:

// working anonymous function  (function () {  window._myglobalfunct("value1");  })() 

but following return anonymous function, within data element, doesn't call function doesn't throw errors? :

// not working doesn't throw errors? return (function() {  var rvalue = document.title || "no title"; window._myglobalfunct(rvalue); return rvalue; })(); 

i know function executing not getting errors in chrome?

dtm's data elements execute code provided within function (that may not clear other users here), there return outside of function in code input/show here. you're not returning value function (or if you're trying update rvalue within function , rvalue isn't in right scope (window vs. local)). in case, there reason you're using anonymous function anyways? below should work:

var rvalue = document.title || "no title"; return window._myglobalfunct(rvalue); 

if still want anonymous function, make sure grab return value function:

return (function() {    var rvalue = document.title || "no title";   return window._myglobalfunct(rvalue); })(); 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -