Created
August 12, 2011 14:29
-
-
Save JasonMore/1142146 to your computer and use it in GitHub Desktop.
Seperating JS from the view
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
@*http://www.telerik.com/help/aspnet-mvc/web-assets-working-with-javascript-web-assets.html*@ | |
@{ | |
Html.Telerik().ScriptRegistrar() | |
.Scripts(script => script | |
.Add("Calldirector.application.js") | |
) | |
.OnDocumentReady(@<text> | |
CallDirector_application.selectedMenuActionId('@(Url.Action("foo"))'); | |
</text>); | |
} |
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
//javascript namespacing | |
//start class | |
var CallDirector_application = {}; | |
(function () { | |
//private members | |
var $selectedMenuAction; | |
//public memeber | |
this.selectedMenuActionId = function (id) { | |
$selectedMenuAction = $('#' + id); | |
} | |
//end class | |
}).apply(CallDirector_application); |
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
<script src="../../Scripts/Calldirector.application.js" /> | |
<script type="text/javascript"> | |
//document onload | |
$(function () { | |
CallDirector_application.selectedMenuAction('@(Url.Action("foo"))'); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment