User:NoseOfCthulhu/Sandbox1

AJAX table loading User:NoseOfCthulhu/Sandbox1

AJAX table loading User:NoseOfCthulhu/Sandbox2

AJAX table loading User:NoseOfCthulhu/Sandbox1/3

AJAX notes
This section attempts to detail various mechanics of AJAX functionality (aka "Ajax") on Terraria Wiki. The featured content do not follow any specific topic or order, and is merely listing information which is assumed to be of interest.

Issues
When loading pages with AJAX, certain elements on the target pages can normally excluded by embedding them inside. This does however not always work, and often the content will be loaded anyway. This is caused by certain interfering elements that doesn't comply with AJAX. Examples of such elements are:
 * Templates:
 * 
 * 
 * 
 * 
 * 
 * Indent colon

In all these cases, the element will be loaded regardless of whether it's embedded in  or not. Additionally, interfering elements will similarly reveal non-interfering elements if the former is included in the same  as the latter.


 * Solutions:
 * Hiding interfering content with  will prevent interference. This way, info can still be present on the page in source-form.
 * (x5) can replace a colon indentation; however probably only under certain circumstances to not itself interfere with page formatting.
 * Interfering content can be turned non-interfering by placing it inside an invisible table and adding . This will however produce a tiny colored square when loaded (see top AJAX load for example).
 * It is not possible to hide this square with additional.
 * Every such table will produce a square. While a single square is hardly notable, multiple ones will form a column.
 * It is possible to use a table to make a whole article " -friendly" and then remove specified parts of it with, but this will similarly affect the loaded page's background color.
 * Being inside a table will alter the appearance of some elements, such as placement. This can bring issues to the target page itself. Table options such as  can presumably solve it.

Alignment
The alignment of AJAX-loading content is specified by the  parameter. Typical alignments are,  ,. This will also affect the alignment of the text within the  parameter. Alternate ways of aligning the content are:

Notice that both solutions can be used to set differents alignment for loaded content and  content.
 * The text (on loaded page) can be embedded into an invisible table like above and then aligned with  where ALIGNMENT is ,  , or  . Such a table will however alter the background color of the text on the loading page.
 * Content can similarly be embedded in CONTENT . This does not cause discoloration and is arguably the best solution.

Loaded content

 * Template inclusion tags
 * AJAX can be used to load Templates (an example being the section of Recipes). This is often a better alternative than having the loading page display the template by normal standard if the template includes a large amount of content. However, AJAX and templates do not load content in the exact same manner. AJAX will always load pages as they appear on their "own" pages while the display of templates can be manipulated with template inclusion tags. For example, a template featuring the following formatting:
















 * ...will display the following when loaded as a template on a page:
 * {| class="terraria" style="text-align:center"

! width="20px" | Nr || width="100px" | Product
 * 1 ||
 * 2 || INCLUDEONLY
 * }
 * When loaded through AJAX it will display as:
 * {| class="terraria" style="text-align:center"
 * When loaded through AJAX it will display as:
 * {| class="terraria" style="text-align:center"

! width="20px" | Nr || width="100px" | Product
 * 1 || NOINCLUDE
 * 2 ||
 * }
 * Hence, in this case, AJAX and template-function will load the content in opposite ways.
 * }
 * Hence, in this case, AJAX and template-function will load the content in opposite ways.


 * Other
 * AJAX can not load AJAX-loaded content through another page. For example, if page A loads B through AJAX, then C cannot load B by loading A.
 * C can however load B if B is a template page, but only if A loads it as a.
 * AJAX can not load collapsible tables. Attempting to do this will load table content as if it was a non-collapsible table.
 * AJAX can load TOC.

AJAX-imitating collapsible table
Below is a collapsible table designed to imitate an AJAX template. It can be used for content which arguably doesn't need its own page while retaining an uniform design when in combination with AJAX templates. It can also be used as a test function to get an idea of how something would look in AJAX.

A regular AJAX template:

A collapsible table imitating an AJAX template:

Formatting:


 * Notes
 * This table is based on a collapsible ordered list which means part of the left loaded area is "unavailable" due to being reserved for number lineup. For balancing, this table has been set to feature a margin on the right. As such, only part of the center can actually feature content.
 * Normal toggle text of this table type features black brackets ( [click here to reveal the list ] ), which is omitted by the above design to further imitate AJAX while removing number markup. This also hides any text not embedded in a table. An alternative is to remove  and replace   with.
 * Tables on Terraria Wiki usually use . In this case,   can be used for further AJAX imitation (for the content table).
 * Specifying  for the content table is recommended as it creates equal left and right margins for non-plainlinks tables. If plainlinks are specified this will seemingly happen whether 100% is added or not, though 100% will still expand the content table to its maximum width.
 * See User:NoseOfCthulhu/Sandbox1/3 for examples.