Created
April 14, 2013 20:15
-
-
Save mauritslamers/5384031 to your computer and use it in GitHub Desktop.
example for load from disk
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
MyApp.statechart.sendEvent("loadData",[{ folder: "name": files: ["filename1.js"] }]); |
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
MyApp.statechart = SC.Statechart.create({ | |
rootState: SC.State.design({ | |
initialSubstate: 'LOAD_DIR_STRUCTURE', | |
LOAD_DIR_STRUCTURE: SC.State.design({ | |
enterState: function(){ | |
MyApp.loadingPane.append(); | |
return SC.Async.perform('load'); | |
}, | |
script: null, | |
load: function(){ | |
// inject script tag | |
var script = document.createElement('script'); | |
script.type= 'text/javascript'; | |
script.src= 'helper.js'; | |
this.script = script; | |
document.appendChild(script); | |
}, | |
loadData: function(data){ | |
if(!data) throw "False data"; | |
data.forEach(function(rec){ | |
var id = rec.folder; | |
MyApp.store.pushRetrieve(MyApp.myModel,id,rec); | |
}); | |
this.resumeGotoState(); | |
document.removeChild(this.script); | |
this.script = null; // prevent leak | |
this.gotoState('MAIN'); | |
} | |
}), | |
MAIN: SC.State.design({ | |
}) | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment