I am using a javascript function that is supposed to invoke on page load complete (like JQuery's function) heres what it looks like:
<script>
var ready = function(fn) {
// Sanity check
if (typeof fn !== 'function') return;
// If document is already loaded, run method
if (document.readyState === 'complete') {
return fn();
}
// Otherwise, wait until document is loaded
// The document has finished loading and the document has been parsed but sub-resources such as images,
//stylesheets and frames are still loading. The state indicates that the DOMContentLoaded event has been fired.
document.addEventListener('complete', fn, false);
};
ready(function() {
alert(lang);
Load(@Model.Language); //<--this is what I want called
});
</script>
------->MVC Stuff<-------
function Load(lang) {
switch (lang) {
case 'Other':
BuildBox("text/text");
case 'CSharp':
BuildBox("text/x-csharp");
break;
}
When I set the breakpoint at the Assignment from the model, we're hitting it. However, nothing else ever happens (including the alert box. I'm not sure why it is not executing the function fully upon load.