问题
Hello I've made a container in DNN but i don't know how to implement jquery script to the container. Does anybody know how this is done?
Best Regards
回答1:
To do it properly, you'll need to write some code (which you can do inside of your container). First, you'll want to request jQuery from the framework. Then, add your plugin script (the best way is probably to use Page.ClientScript, so that the script doesn't get added multiple times when the container is used multiple times on the page.
<script runat="server">
Sub Page_Init(ByVal sender as Object, ByVal e as EventArgs) Handles Me.Init
DotNetNuke.Framework.jQuery.RequestRegistration()
Me.Page.ClientScript.RegisterClientScriptInclude("myscript", ResolveClientUrl("scripts/jquery.myplugin.js"))
End Sub
</script>
I would probably alter the plugin script and include a call at the end to call the plugin on whatever elements you're enhancing:
jQuery(function ($) {
$('.my-container .header').pluginize();
});
来源:https://stackoverflow.com/questions/5339988/dotnetnuke-jquery-script-in-container