Homepage | Products | OX Knowledge Base | Support | Try Now | Contact | Company
OX Logo
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2013
    Posts
    6

    Default application with external dependencies

    Hi,

    I have an application written in pure html & javascript, now I want to convert it to OX AppSuite's application. I then write register.js file like below:

    register.js
    PHP Code:
    define('my.namespce/myapp/register', ['my.namespace/myapp/myclass'], function (myclass) {
        ...
    }); 
    myclass in turn, require lots of external scripts & most of them are utility module which are included into dom tree by <script> tag in the old fashion style.

    The question is: How can I include those dependencies?

    Thanks

  2. #2
    Join Date
    Feb 2007
    Posts
    253

    Default

    OX App Suite uses RequireJS, so if your external dependencies are AMD modules, or have any other kind of support for RequireJS, you could try to use that.

    Otherwise, you can use
    Code:
    //@include filename
    to include plain JavaScript inside your own module without polluting the global namespace. The filename should be relative to the directory of the JavaScript file in which this include directive appears.

  3. #3
    Join Date
    Oct 2013
    Posts
    6

    Default

    Hi Vik,

    Unfortunately, neither the //@include nor require() does work

    For example: in register.js I include/require lib1.js & mod1.js. mod1.js has some calls to lib1.js functions. Build tool failed to work with method not found error.

    The build tool also doesn't work & stop with "'<something>' not defined" error when I call browser's api. For example: calling to webkitURL() method of Chrome will raise 'webkitURL' not defined & the builder refuses to continue.
    Last edited by dollylamb; 02-17-2014 at 06:22 AM.

  4. #4
    Join Date
    Feb 2007
    Posts
    253

    Default

    The build system uses JSHint to check the source. You can customize the errors and warnings either globally for your app using a .jshintrc file or locally using comments. The preferred method is to add the native APIs to the "global" option, so that JSHint knows, what's an API and what's a typo.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •