Created
June 3, 2015 13:45
-
-
Save Tallies/7640b4b810b7caf15c88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loadContent = function(name, success, fail){ | |
$.ajax({ | |
url:name+ "/get", | |
type:"GET", | |
dataType:"json", | |
success: function(data) { success(name, data); }, | |
error: fail | |
}); | |
}; | |
//Create and mount the components | |
var headerMountNode = document.getElementById("react-header-node"); | |
React.render(React.createElement(Header, { title: initialData.header.title, headerImageLeft:initialData.header.headerImageLeft, headerImageRight: initialData.header.headerImageRight }), headerMountNode); | |
var page = getPage(); | |
var menuMountNode = document.getElementById("react-menu-node"); | |
var menu = React.render(React.createElement(Menu, {active:initialData.menu.active, menuClickHandler: menuClickHandler}), menuMountNode); | |
//For contentPanel, we need to fetch the content first | |
var contentPanelMountNode = document.getElementById("react-content-panel-node"); | |
var contentPanel; | |
loadContent(initialData.contentPanel.content, | |
function(name, data){ | |
contentPanel = React.render(React.createElement(ContentPanel, {content: data.contentPanel, loadingImage: initialData.contentPanel.loadingImage}), contentPanelMountNode); | |
}, | |
function(xhr, status, error){ | |
content = "Error loading content. " +status +" - " + error ; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment