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

Re: Beginner Questions

Expand Messages
  • silversturm
    Hey Mike! Thanks for the very immediate and thorough response! I do apologize for not being as quick with mine. Thanks also for investigating the FF issue so
    Message 1 of 4 , Jun 24, 2010
    • 0 Attachment
      Hey Mike!

      Thanks for the very immediate and thorough response! I do apologize for not being as quick with mine. Thanks also for investigating the FF issue so in-depth. It's not that big a deal, but you can imagine it made learning this stuff a pain :P I'm guessing that in general real files that are included like this rarely have alert/confirm/prompt boxes at the top level like that, but rather have function/variable/class declarations (correct me if I'm wrong) - so the FF bug is a minor one.

      There is one other fundamental thing that I am struggling with - when included files take effect such that their contents are available to subsequent code. Or more straight to the point, I am interested in discussing the text in the Ajile help: "The browser will not process the loaded module until the currently executing module or HTML script block is completely processed or executed."

      I'm really trying to understand this in-depth so I apologize for the plethora of questions.

      1. Is the core strategy Ajile uses to include other script files dynamically something like this? Is it the same in all browsers?
      var e = document.createElement("script");
      e.src = someURL;
      e.type="text/javascript";
      document.getElementsByTagName("head")[0].appendChild(e);

      2. Regardless of how Ajile includes script files dynamically, is the dynamically loaded script file supposed to be interpreted by the browser right at the end </script> tag of the block that performed the dynamic inclusion/loading?

      3. With Ajile, there can be MVC files ("X.js" for a given "X.html") and the shared "index.js" files. I believe I understand the purpose of both. Let's say both MVC and MVCSHARE are enabled. Theoretically you only have to include your "ajile.js" file in your HTML file as hinted to by the documentation. This implies that "ajile.js" will automatically include both "index.js" and "X.js". Are the contents of both these files applied at the end </script> tag for "ajile.js"? I figured they would be, but maybe it depends on how Ajile loads these files dynamically. Here is a specific problem related to this:

      Dir Contents:
      - com.derek.Person.js
      - com.iskitz.ajile.js
      - index.js
      - main.html
      - main.js

      === main.html ===
      <html>
      <head>
      <script type="text/javascript" src="com.iskitz.ajile.js?mvc,mvcshare"></script>
      <title>TEST</title>
      </head>
      <body>
      <h1>hello</h1>
      <script language="javascript">
      var v = new Person();
      v.sayHi();
      </script>
      </body>
      </html>

      === main.js === (1 line)
      Import("com.derek.Person");

      === index.js === (0 lines)

      === com.derek.Person ===
      Namespace("com.derek");
      com.derek.Person = function() {
      this.name = 'Tony';
      this.sayHi = function() {
      alert("Hi I'm " + this.name + ".");
      };
      };

      I was under the impression that Ajile would include index.js, main.js and then by the end of the <script> tag for "ajile.js", everything would be available. Are my assumptions correct? Are there any gotchyas or things to watch out with the order of inclusion?

      I'm asking because on my Mac (my previous post I was testing on Windows) the above code seems to work fine in FF 3.6.3, but Safari 5.0 croaks with "ReferenceError: Can't find variable: Person" (I have developer tools enabled on it). Any ideas?

      4. What if I do not want to use either index.js nor main.js (for understanding's sake) - then I WOULD have to have at least some other <script> tag in my HTML file to include the appropriate libraries before I reference them later in "main.html", correct? Either:
      <script type="text/javascript" src="com.derek.Person"></script>
      or
      <script language="javascript">
      Import("com.derek.Person");
      </script>
      Correct?

      These questions pretty much sum up my confusion with order of inclusion. Any help you can give would be much appreciated (if you have time).

      Thanks much!
      Derek

      --- In ajile@yahoogroups.com, "iskitzdev" <yahoo@...> wrote:
      >
      >
      > Hi Derek,
      >
      > I still haven't found the root cause of the Firefox hang, but I did notice that this problem only seems to happen if the loaded script immediately executes either an alert(), confirm(), or prompt() statement. Substituting any of those with an alternate implementation (i.e. console.log instead of alert) resolves the issue.
      >
      > My current thought is that statements like alert, confirm, and prompt that create modal dialogs, interrupt the DOM writing process.
      >
      > What I'm seeing is that script blocks immediately following the ajile block in the page's markup seem to be lost if the user is prompted during the script loading process.
      >
      > I went back to Firefox 2 and don't see this problem using the exact code so i suspect Firefox changed DOM processing with respect to modal dialogs somewhere along the line in Firefox 3.
      >
      > I'll keep digging, but for now I'd recommend doing the following:
      >
      > - Install and enable the Firebug extension
      > - Replace your alert statement(s) with console.log
      >
      > It may be that I have to file a bug against Firefox for this issue, but I want to debug a bit more to see if there's anything i can do in Ajile to work around or fix the issue.
      >
      > Thanks for letting me know about this.
      >
      > Mike
      >
      > --- In ajile@yahoogroups.com, "iskitzdev" <yahoo@> wrote:
      > >
      > > Hi Derek,
      > > To answer your questions:
      > >
      > > > 1. First, what is the difference between the three 'com.iskitz.ajile*.js' files in 'lib'? When to use which?
      > >
      > > com.iskitz.ajile.1.2.1.flat.js is for debugging. It uses the human readable names for all defined variables and functions.
      > >
      > > com.iskitz.ajile.js is the compressed version for minimized download time. The build-time compression process shortens and renames internal variable and function names. This file is intended for use in environments where you simply want to drop in the latest Ajile implementation without having to update your HTML to point to the new version. Since this file's name doesn't include the Ajile API version it can easily be overwritten with earlier or later Ajile releases.
      > >
      > > com.iskitz.ajile.1.2.1.js and com.iskitz.ajile.js have identical content, but com.iskitz.ajile.1.2.1.js contains the Ajile API version in its name so that you can keep multiple versions of Ajile in the same directory but easily distinguish between them at load time. This is intended for use in environments where you've written code that depends on a specific version of the Ajile API.
      > >
      > >
      > > > 2. Once you've decided on which JS file you need, what are the different arrangements of where you can place it?
      > >
      > > You can place your com.iskitz.ajile[.version].js file anywhere you'd like. When you load the file in your HTML, Ajile will use its location as the default location for scripts loaded via Import, ImportAs, and Include statements.
      > >
      > >
      > > > Name-style vs. Path-style. Are these the only two options? When does each method make more sense to use (i.e. pros/cons)?
      > >
      > > The decision of whether to use name-style or path-style is the developer's.
      > >
      > > Ajile's default loading style will be set based on which style was used to load Ajile itself. Loading Ajile via com/iskitz/ajile.js will set the default loading style to path-style. Using com.iskitz.ajile.js will set it to name-style.
      > >
      > > Ajile will use the default loading style for all Import, ImportAs, and Include statements that don't explicitly specify a loading style as defined at: http://ajile.net/docs/api/Directives.htm
      > >
      > > If you prefer to group your scripts into directories and sub-directories you should use path-style. Otherwise name-style is recommended. By default Ajile uses name-style. I prefer that approach because it allows me to group functionality into single scripts which can all be stored in the same directory but exist in different namespaces identified by their file names. For example:
      > >
      > > + scripts/
      > > - com.iskitz.ajile.examples.js
      > > - com.cnn.feeds.js
      > > - derek.modules.js
      > >
      > > vs.
      > >
      > > - scripts/com/iskitz/ajile/examples.js
      > > - scripts/com/cnn/feeds.js
      > > - scripts/derek/modules.js
      > >
      > > Name-style and path-style don't have to be mutually exclusive. The namingStyle parameter of Import, ImportAs, Include, or Namespace statements can be used to switch between the two approaches at run-time as documented at: http://ajile.net/docs/api/Directives.htm
      > >
      > > Specifying the style via a Namespace statement will set the default loading style for modules subsequently loaded into that namespace.
      > >
      > >
      > > 3. Hanging and errors with your atest.html and atest.js:
      > >
      > > By default Ajile will load both the shared index.js control script and your page's control script. In your setup, Ajile tries to load the following:
      > >
      > > /scripts/index.js - shared control script
      > > /atest.js - your page's control script
      > >
      > > Since you don't have a /scripts/index.js you need to use mvcshareoff to disable Ajile's default behavior of loading the shared control script.
      > >
      > > If you want to also disable automatically loading your page's control script you could use mvcoff (i.e. src="scripts/com/iskitz/ajile.js?mvcoff,mvcshareoff"). mvcoff is useful if you're only using a shared controller or inline JS (JS within your HTML).
      > >
      > > The hanging behavior only seems to occur in Firefox so I'll look into what Firefox differences might be causing that behavior.
      > >
      > > Good luck!
      > >
      > > Mike
      > >
      > >
      > > --- In ajile@yahoogroups.com, "silversturm" <silversturm@> wrote:
      > > >
      > > > I apologize for the beginner questions, as I am looking forward to using Ajile but am having difficulty getting it set up just by reading the documentation alone. If there is a help/faq page that answers these kinds of questions, please let me know.
      > > >
      > > > 1. First, what is the difference between the three 'com.iskitz.ajile*.js' files in 'lib'? When to use which?
      > > >
      > > > 2. Once you've decided on which JS file you need, what are the different arrangements of where you can place it? So far on this help forum I've heard about name-style where you put the fully-named 'com.iskitz.ajile*.js' file somewhere near the HTML files in '/', '/js', or '/script', etc. Then you specify in each HTML file
      > > >
      > > > <SCRIPT type="text/javascript" src="scripts/com.iskitz.ajile.js"></SCRIPT>
      > > >
      > > > Or, there is path-style where you create a 'com/iskitz' dir in '/', '/js', '/scripts', etc. and rename the chosen file in lib to 'ajile.js' and place it in there. Then you reference from HTML using:
      > > >
      > > > <SCRIPT type="text/javascript" src="scripts/com/iskitz/ajile.js"></SCRIPT>
      > > >
      > > > Are these correct? Are these the only two options? When does each method make more sense to use (i.e. pros/cons)?
      > > >
      > > > 3. Lastly I have an extremely simple setup that for some reason is hanging on me when I load the page.
      > > >
      > > > Dir structure:
      > > > +/
      > > > -atest.html
      > > > -atest.js
      > > > ++/scripts/com/iskitz
      > > > --ajile.js
      > > >
      > > > == atest.html ==
      > > > <html>
      > > > <head>
      > > > <script type="text/javascript" src="scripts/com/iskitz/ajile.js"></script>
      > > > </head>
      > > > <body>
      > > > <h1>hello</h1>
      > > > </body>
      > > > </html>
      > > >
      > > > == atest.js == (1 line)
      > > > alert('atest.js test');
      > > >
      > > > When atest.html is loaded, FF 3.6.3 shows alert then loads forever. IE 6 & 8 shows an error on line 0 of the non-existent 'scripts/index.js'. But when I add 'scripts/index.js', IE loads but FF still hangs after the alerts. I know there are options for mvc and mvcshare but when I used '.../ajile.js?mvcshareoff' FF still hangs.
      > > >
      > > > I'm clearly missing some key concepts of using Ajile. Any help you can provide would be greatly appreciated. :) Thanks so much.
      > > >
      > > > Derek
      > > >
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.