noClonflict () jQuery - Does not work anymore

2

Hello, I was using jQuery's noClonflict () to have no conflict with the site link

Initially it worked, but after a few days is giving trouble again. It is conflicting with the lojaintegrada classes.

I was not able to get rid of the clonbites between classes.

I tried to change $ j to another name and it did not work.

<script src="http://code.jquery.com/jquery-latest.min.js"type="text/javascript">/script>
<script>
var $j = jQuery.noConflict();
(function ($j) {
    $j(document).ready(function () {
        $j('#cssmenu').prepend('<div id="indicatorContainer"><div id="pIndicator"><div id="cIndicator"></div></div></div>');
        var activeElement = $j('#cssmenu>ul>li:first');

        $j('#cssmenu>ul>li').each(function () {
            if ($j(this).hasClass('active')) {
                activeElement = $j(this);
            }
        });

        var posLeft = activeElement.position().left;
        var elementWidth = activeElement.width();
        posLeft = posLeft + elementWidth / 2 - 6;
        if (activeElement.hasClass('has-sub')) {
            posLeft -= 6;
        }

        $j('#cssmenu #pIndicator').css('left', posLeft);
        var element, leftPos, indicator = $j('#cssmenu pIndicator');

        $j("#cssmenu>ul>li").hover(function () {
            element = $j(this);
            var w = element.width();
            if ($j(this).hasClass('has-sub')) {
                leftPos = element.position().left + w / 2 - 12;
            } else {
                leftPos = element.position().left + w / 2 - 6;
            }

            $j('#cssmenu #pIndicator').css('left', leftPos);
        }, function () {
            $j('#cssmenu #pIndicator').css('left', posLeft);
        });

        $j('#cssmenu>ul').prepend('<li id="menu-button"><a>Menu</a></li>');
        $j("#menu-button").click(function () {
            if ($j(this).parent().hasClass('open')) {
                $j(this).parent().removeClass('open');
            } else {
                $j(this).parent().addClass('open');
            }
        });
    });
})(jQuery);

</script>
    
asked by anonymous 15.05.2015 / 16:10

1 answer

1

Attempts to pass jQuery.noConflict() to your IIFE (and remove var $j = jQuery.noConflict() from global scope):

<script>
(function ($j) {

    /* código ... */

})(jQuery.noConflict());

</script>
    
16.07.2015 / 04:21