DotNetNuke Jquery doesnt work in module

2019-09-16 03:20发布

问题:

I have a JQuery file that works fine on a normal webpage, but doesn't work inside of DNN.

DNN is pointing at the latest version of JQuery in the Host settings I have a container called news containing (news.css, news.ascx) and a module called newsdata.ascx inside of the container.

I have this code in the module to start launch the JQuery file:

<script type="text/javascript">
    $(function() {  
        $("#controller").jFlow({  
            slides: "#slides",  
            width: "277px",  
            height: "150px",  
            duration: 250  
        });  
    });  
</script>

But nothing happens. Am I placing the code in the correct locations?

Thanks

回答1:

I would guess that you've run into an issue where $ isn't referring to jQuery. Try changing the first line to jQuery(function ($) {



回答2:

I figured this one out the hard way. To get your jQuery working on a DNN page, you must first instantiate it. To do this:

 DotNetNuke.Framework.jQuery.RequestRegistration()

If you don't the core jQuery may never be added to the page.

http://www.dotnetnuke.com/Resources/Wiki/Page/jQuery.aspx