javascript - method with parameter in unknown js function issues -


i'm trying protect part of js code wrapping code unknown function.

i have edit function change

function banana(url) {} 

to method

banana: function(url){ }, 

when try call function banana in function try use

this.banana(url); 

but have error:

typeerror: this.banana not function 

full code:

(function (){   var url_test = "./add_user.php?opt=get_user&token=<?php echo $token; ?>";   if (typeof $.customfnc == 'undefined')      $.customfnc = {}    $.customfnc.get = {       setup: function (){         var url = "google.ca";         this.banana(url);       },       banana: function (url){          console.log("my url: " + url);       };    };  };    // on ready render data   $(document).ready(function() {     $.customfnc.get.setup();   }); })(jquery); 

thanks help!

the issue here scope of 'this' not might think is.

the way have handled particular issue in past add

var self = this;  

outside of object attempting self reference. may impact how have set youre .get() object though.

$.customfnc.get = function(){     var self = this;      self.setup = function (){         //....        self.banana(url)     }     self.banana = function(url){          //...     } } 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -