1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Extending my Javascript Library

Discussion in 'JavaScript' started by ::Mike::, Jan 21, 2010.

  1. #1
    So essentially this is my current library setup
    
    var myLib = function(e){
    	this.version=0.4;
    	this.e=e;
    	this.css = function(){
    		
    	};
    	if(this instanceof myLib)
    		return this.myLib;
    	else
    		return new myLib(e);
    }
    Code (markup):
    But its getting too big and I'm wanting to put other functions in other files.
    E.g this is myLib.js but then I want say another file called myLib_ajax.js which still uses the myLib global variable.

    How would i be able to do this and is it possible with my current setup?
     
    ::Mike::, Jan 21, 2010 IP
  2. unigogo

    unigogo Peon

    Messages:
    286
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sure you can, extend the prototype chain of myLib to ajax object.

     
    unigogo, Jan 21, 2010 IP
    ::Mike:: likes this.
  3. ::Mike::

    ::Mike:: Peon

    Messages:
    826
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Just the answer I was looking for thanks!!
     
    ::Mike::, Jan 21, 2010 IP