javascript - Directly refer to a function in PeerJS -


for project i'm using javascript library called peerjs webrtc stuff. had code build this

$(function(){     peer.on('open', function(id) {         //stuff done     });      //more functions  }); 

but have load when dom ready , code became quite mess decided make seperate function it.

$(function(){     peer.on('open', function(id) {         peeropen(id);     });      //more functions });  function peeropen(id){     //stuff done };  //more functions 

but seems comprehensive tried this:

$(function() {     peer.on('open', peeropen());      //more functions });  function peeropen(id){     //stuff done };  //more functions 

but isn't working me, doing simple wrong or thing try impossible?

$(function() {     peer.on('open', peeropen);      //more functions });  function peeropen(id){     //stuff done }; 

you need pass in function reference! in example, calling function.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -