容器中的DotNetNuke jQuery脚本 [英] DotNetNuke jquery script in container

查看:114
本文介绍了容器中的DotNetNuke jQuery脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好 我已经在DNN中制作了一个容器,但是我不知道如何对该容器实现jquery脚本. 有人知道这是怎么做的吗?

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?

最好的问候

推荐答案

要正确执行此操作,您需要编写一些代码(可以在容器内部执行).首先,您需要从框架中请求jQuery.然后,添加您的插件脚本(最好的方法可能是使用 Page.ClientScript ,以便在页面上多次使用容器时不会多次添加脚本.

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();
});

这篇关于容器中的DotNetNuke jQuery脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆