1175 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
mabuc says

Hello jquery masters,

I have a custom page loading like this
var $j = jQuery.noConflict();
$j(function() {
    var b = $j('#container').hide(); 
    $j(window).load(function() {
        b.fadeIn(1000);
        $j("#loading").hide();   
    });
}); 

and I have a scrollbar that goes like this

var $j = jQuery.noConflict();
$j(window).load(function() {
    mCustomScrollbars();
});

my problem is that scrollbar is not working because window.load() is called twice.. can anyone help me on what possible fix should I apply on this..

thank you in advance… :)

1675 posts Envato Elite Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a Free File of the Month
  • Exclusive Author
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Europe
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
+1 more
Tean says

Why dont you call mCustomScrollbars(); in your first $j(window).load(function() {...} block?

1043 posts
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
fillerspace says
I’m assuming the second window load function can’t be included in the first block because it will be written by a plugin or shortcode?
var $j = jQuery.noConflict();
$j(function() {
    var b = $j('#container').hide(); 
    $j(window).load(function() {
        b.fadeIn(1000);
        $j("#loading").hide();   
    });
}); 
$j(function() {
  $j(window).load(function() {
      mCustomScrollbars();
  });
});

This way worked for me (note that the second window load is wrapped in a $j() function)

1175 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
mabuc says

Why dont you call mCustomScrollbars(); in your first $j(window).load(function() {...} block?
thanks for the help, I just made it this way:
$j(function() {
    var b = $j('#container').hide(); 
    $j(window).load(function() {        
        b.fadeIn(1000);
        $j("#loading").hide(); 
        mCustomScrollbars();      
    });
});
by
by
by
by
by
by