Loading ...
Sorry, an error occurred while loading the content.

Re: Problem using the directory-based approach

Expand Messages
  • mikeizworkin
    Hi, Thanks for providing so much info about the problem you ve run into. Before I go into a full explanation, the short answer for your specific code is to
    Message 1 of 4 , Mar 16, 2010

      Thanks for providing so much info about the problem you've run into. Before I go into a full explanation, the short answer for your specific code is to make the following changes:

      ... src = "com/iskitz/ajile.js?cloakoff,mvcshareoff" ...

      Include ("com.testsite.page.sidebar.Test2", null, '/');

      The above line will cause the "com.testsite.page.sidebar" namespace to default to directory-based loading for that and all subsequent Include, Import, and ImportAs of modules using that namespace. After the line above executes any of the following will trigger directory-based loading:

      Include ("com.testsite.page.sidebar.Test");
      Include ("com.testsite.page.sidebar.more.nesting.SomeModule");

      More detail. Namespace, Import, ImportAs, and include can all be used to define the loading style (directory or file) for a given namespace.

      The third parameter in the following statement indicates which character Ajile should use to translate the specified Namespace from dot-notation to its file-system representation.

      Namespace ("your.name.space", "/optional/location/", '/');

      Import ("your.Module", "/optional/location/", '/');

      ImportAs ("Module", "your.Module", "/optional/location/", '/'); // fourth parameter here

      Include ("your.Module", "/optional/location/", '/');

      Using Include, Import or ImportAs with any module within the same or a nested namespace will cause it to be loaded from: /optional/location/your/name/space/

      Substituting '.' for '/' is equivalent to file-based loading using dot-notation.

      For details see:


      You might also find it useful to use the "debug" load-time option to get more information about Ajile's operations. When working in an environment that supports console.* (i.e. Firebug) you'll be able to observe Ajile's sequence of actions. This also works with WebKit's console. In environments without console support you can explicitly use Ajile.ShowLog() to display information about Ajile's operations. Ajile.ShowLog() requires pop-up blocking to be disabled.

      To use multiple load-time options use the following syntax:

      ... src = "com/iskitz/ajile.js?option1,option2,option3" ...

      The following will cause Ajile to disable module cloaking, enable debugging (console.*), and disable automatically loading an index.js file from the same location as com.iskitz.ajile.


      For more load-time option info see:


      Hope that helps. Definitely post any further questions or additional issues you run into.


      --- In ajile@yahoogroups.com, "strukturgewitter" <strukturgewitter@...> wrote:
      > Hi, im digging up this post because i experience a very similar problem.
      > My file structure is like this:
      > /var/www/test/index.html
      > /var/www/test/com/iskitz/ajile.js (to activate directory base approach)
      > /var/www/test/index.js
      > /var/www/test/com/testsite/page/sidebar/Test.js
      > /var/www/test/com/testsite/page/sidebar/Test2.js
      > File contains:
      > ------index.js------
      > Include('com.testsite.page.sidebar.Test2');
      > Ajile.AddImportListener('com.tessite.page.sidebar.Test2', function(name) {
      > com.testsite.page.sidebar.Test2();
      > });
      > ------Test.js------
      > Namespace('com.testsite.page.sidebar');
      > com.testsite.page.sidebar.Test = function() {
      > alert("Hello World");
      > }
      > ------Test2.js------
      > Namespace('com.testsite.page.sidebar');
      > com.testsite.page.sidebar.Test2 = function() {
      > Include('com.testsite.page.sidebar.Test');
      > Ajile.AddImportListener('com.testsite.page.sidebar.Test', function(name) {
      > com.testsite.page.sidebar.Test();
      > });
      > }
      > ------index.html------
      > <html>
      > <head>
      > <script src="com/iskitz/ajile.js?cloakoff?mvcoff" type="text/javascript"></script>
      > </head>
      > <body>Test</body>
      > </html>
      > ----------------------
      > When i load my page, nothing happens (i also know why [see below])
      > This is what firebug gives me:
      > <html>
      > <head>
      > <meta http-equiv="Powered by Ajile 1.2.1" content="ajile.iskitz.com :: Smart scripts that play nice ">
      > <script title="index" type="text/javascript" src="http://localhost/test/index.js"></script>
      > <script title="com.testsite.page.sidebar.Test2" type="text/javascript" src="http://localhost/test/com.testsite.page.sidebar.Test2.js"></script>
      > <script title="com.testsite.page.sidebar.Test2" type="text/javascript">ImportAs("com.testsite.page.sidebar.Test2", "com.testsite.page.sidebar.Test2");</script>
      > </head>
      > <body>Test</body>
      > </html>
      > The Problem is the following line:
      > http://localhost/test/com.testsite.page.sidebar.Test2.js
      > This not a directory based approach.. i assume
      > Is there any way around this _without_ using
      > Namespace('my.space', null, '/');
      > ?
    Your message has been successfully submitted and would be delivered to recipients shortly.