DotNetNuke jquery script in container

纵然是瞬间 提交于 2019-12-08 07:39:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!