How to avoid jquery conflict in dnn

烂漫一生 提交于 2019-12-06 07:37:28

For example, If you look at /DesktopModules/Admin/HostSettings/HostSettings.ascx you will notice that dnn core developers are using following code:

(function ($, Sys) {
 $(document).ready(function () { 
    //Your code goes here.
 });
}(jQuery, window.Sys));

Apart from this, if you notice the $(document).ready function, they are repeating the same code to handle ajax post backs due to update pane. That will ensure your code will work ok even if module is having ajax enabled.

 $(document).ready(function () {
        setUpDnnHostSettings();
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () {
            setUpDnnHostSettings();
        });
    });

You can also look at other ascx controls in core in admin folder. I hope this will help.

var $j = jQuery.noConflict();
$j(document).ready(function(){
    ...code goes here...
});

Try This,

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