flackr/dungeon

Implement JS function for loading HTML dynamically.

Closed this issue · 1 comments

Summary

The single index.html file is going to get fairly large if everything must be contained within it. We need a library which will pull in other HTML files with the assumption that these loads are asynchronous and you can't access the elements within until it has completed.

Implementation

We should define a property on elements (i.e. <div src="filename.html">) which we will scan for. When this is found we can initiate an asynchronous request for the HTML and insert it. On completion we should fire an event and set an attribute to indicate that the div is "ready". Then we can provide an interface which will fire some callback on loading the div, which will be immediate if the div is already loaded.

Added the file html-include.js which provides the function load(node, func) which will wait for all include nodes (including recursively loaded include nodes) within node have loaded and then call func(node).