javascript - Calling global function in Riot.js expression -


i trying call function declared in global namespace expression in riot.js.

this not work:

<strong>created { getdatestring(item.created) } { item.creator }</strong> 

i can call global moment() function (from moment.js):

<strong>created { moment(item.created) } { item.creator }</strong> 

the overall javascript file containing function is loaded... if call getdatestring() this.on('mount') works:

this.on('mount', function() {     getdatestring(new date()); }); 

i don't understand how namespacing works in riot.js, , can't figure out why call getdatestring() failing in expression succeeding in mount function. can tell me i'm doing wrong?

make sure globalfunction() declared @ global. scope of <script> tag inside tag definition not global. take care it.

<my-tag>   <p>{ someglobalfunction(message) }</p><!-- work -->   <p>{ localfunction1(message) }</p><!-- won't work -->   <p>{ localfunction2(message) }</p><!-- work -->   <p>{ localfunction3(message) }</p><!-- work -->    <script>     this.message = 'world'      // not reachable template     function localfunction1 (arg) {       return 'hello ' + arg + '!'     }      // reachable because same localfunction3     localfunction2 (arg) {       return 'hello ' + arg + '!'     }      // reachable template     this.localfunction3 = function(arg) {       return 'hello ' + arg + '!'     }.bind(this)   </script> </my-tag> 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -