> Thanks very much for your reply and the information. What I'm hoping > to be able to do is to provide a plug-in API for my jQuery plug-in > which will allow the new API functions to be able to access the > private methods which I use. I know you can't force something to > expose private methods (or they wouldn't be private!) but what I was > wondering was if it was possible to allow access to those methods if > you know that you want to do this (without making everything > public)... > > Here is the basic idea for what I want to do in code (and with the > eval/toString method I described above): > > fnApi = function () { > console.log( 'API function is running with required scope: > '+iPi ); > } > > fnContainer = function () { > var iPi=3.141592; > > this.fnApi = eval( '('+ fnApi.toString()+')' ); > }; > > var oContainer = new fnContainer(); > oContainer.fnApi(); > > Many thanks, > Allan
Here's one approach (view source): http://jquery.malsup.com/test/feb14.html