Hybrid View

  1. #1
    Sencha User chrizmaster's Avatar
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    441
    Vote Rating
    1
    chrizmaster is on a distinguished road

      0  

    Default Using a js file in another (object orientated)

    Using a js file in another (object orientated)


    Hi there,

    is this possible?

    I would like to create a file called util.js. Now i put some functions in there, which i will need often. And I now would like to usw this functions in all my other javascript files.
    I thought this has something to do with Ext.ns('...') but seems not to be right.

    So is this possible and if yes, how?

    Thanks
    Chriz

  2. #2
    Sencha User chrizmaster's Avatar
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    441
    Vote Rating
    1
    chrizmaster is on a distinguished road

      0  

    Question


    mhm seems that I got it. I now use namespace and do something like that:

    Ext.namespace("bla");

    bla = function(){
    //do some stuff
    }

    if I initialize this utilities js file in the html file BEFORE I use my main js file, i can use it there.

    Just one question remains:
    is there a possibilities to init the utilities file from another javascript file, or do i have to init this like <scrip language="text/javaScript" src=""></script> in the html file?

    Chriz

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    namespace just creates variables/objects. It has nothing to do with loading javascript. If you want to include the file, just add the script tag.

  4. #4
    Sencha User chrizmaster's Avatar
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    441
    Vote Rating
    1
    chrizmaster is on a distinguished road

      0  

    Default


    just add the script tag?

    So that means I have to add the <script language="text/javascript"...> tag into the html file. I cant load the js file like I do in Java (Utilities u = new Utilities())

    Right?

    Is the namespace thing a good possibility to use Methods in other javascript files?

    Chriz

  5. #5
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    Once again - the 2 are unrelated.

    Read the API doc for namespace http://extjs.com/deploy/dev/docs/?cl...mber=namespace

    It has nothing to do with loading javascript.

    If you're asking about dynamically loading javascript files, there are ways to do this. I suggest you spend some time reading the http://extjs.com/learn, so you have a better understanding and can formulate some questions that make clear what you're trying to accomplish.

Thread Participants: 1