Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not 100% sure I get what your issue but what you can do, especially if we are talking about a single page style AJAX application is to use Singletons classes geared toward specific tasks.</p> <pre><code>var XMLFormatter = function(){ /* PRIVATE AREA */ /* PUBLIC API */ return { formatXML : function(xml){ /* DO SOMETHING RETURN SOMETHING */ } } }(); </code></pre> <p>What you are left with is a static XMLFormatter class that can be called anywhere on the page like so...</p> <pre><code>function useClass(){ $('#test').update(XMLFormatter.formatXML(someXML)) } </code></pre> <p>This function can be used as a callback on the AJAX requests. I use this method for page logic by creating a Page class taht returns an object with an init method that is called when the page is loaded. The init method then attaches the various events and stuff to my page and it's elements. This is approach is talked about in <a href="http://apress.com/book/view/159059908x" rel="nofollow noreferrer">Pro JavaScript Design Patterns</a> well worth the read if you have the time and money.</p> <p>It's also worth bearing in mind that Javascript is quite different in comparison to other languages and usually peoples best-practise approaches are usually just ones adapted from Java. While this is OK it's not using Javascript to it's full potential. Remember Javascript is quite event driven due to it's closeness to UI interaction and you will find a some event code mingling with other code. Crockfords website (<a href="http://javascript.crockford.com/" rel="nofollow noreferrer">http://javascript.crockford.com/</a>) has some best-practice articles plus a number of other useful tips.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload