Skip to content

Instantly share code, notes, and snippets.

@ainsofs
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ainsofs/158ffc99c80a4a02b0b2 to your computer and use it in GitHub Desktop.
Save ainsofs/158ffc99c80a4a02b0b2 to your computer and use it in GitHub Desktop.
DNN Knockout Boiler Template
<!-- requires DNN 7.2 or higher -->
<%@ Register TagPrefix="dnn" TagName="JavaScriptLibraryInclude" Src="~/admin/Skins/JavaScriptLibraryInclude.ascx" %>
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>
<asp:Panel ID="ScopeWrapper" runat="server">
<!-- things to bind here -->
</asp:Panel>
<dnn:JavaScriptLibraryInclude runat="server" Name="knockout" version="3.1.0" />
<dnn:JavaScriptLibraryInclude runat="server" Name="knockout.mapping" version="2.4.1" />
<dnn:DnnJsInclude runat="server" FilePath="/desktopmodules/[moduleName]/path/to/viewModel.js" />
<script type="text/javascript">
//requires jquery
(function($) { //remove from global scope
$(function() {
ko.applyBindings(new viewModel, document.getElementById(<%= ScopeWrapper.ClientID %>);
});
})(jQuery);
</script>
//Sometimes you need to use this
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>
//instead of
<%@ Register Assembly="DotNetNuke.Web" Namespace="DotNetNuke.Web.UI.WebControls" TagPrefix="Portal" %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment