I am trying to organize my code using the object literal pattern, but I am getting an error: Uncaught ReferenceError: backToTop is not defined
Any ideas why?
Here's the code:
(function($){
var Mk = {
config: {},
init: function(config) {
backToTop();
wow();
progressBarAnimation();
slabText();
},
backToTop: function() {
$('body').append('<div id="toTop" class="btn btn-success"><span class="glyphicon glyphicon-chevron-up"></span> Back to Top</div>');
$(window).scroll(function () {
if ($(this).scrollTop() != 0) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});
$('#toTop').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
},
wow: function() {
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 0,
mobile: true,
live: true
});
wow.init();
},
progressBarAnimation: function() {
$.each($('div.progress-bar'),function(){
$(this).css('width', $(this).attr('aria-valuetransitiongoal')+'%');
});
},
slabText:function() {
$("h1.mklife").slabText({
"viewportBreakpoint":400
});
},
last:''
};
$(document).ready(Mk.init());
window.Mk = Mk;
})(jQuery)
- Edit: I had missed the actual function call parentheses on document ready: $(document).ready(Mk.init());