I have multiple functions within plugin that I like to call through out but for some reasons I get methods undefined.
If I don't use methods to wrap the functions I get
function statement requires a name
- What am I doing wrong here?
do I need to wrap the functions with methods var?
(function ($) { var methods = { // GET TARGET LOCATION AND ANIMATE scrollTopPage: function () { $(htmlBody).animate({ scrollTop: 0 }, 'slow'); }, scrollToSect: function (htmlBody) { $(htmlBody).animate({ scrollTop: $('#page-id').offset().top }); }, goToID: function (sectID) { var htmlBody = 'html,body'; //Scroll to the very top if (sectID == 'home') { methods.scrollTopPage(htmlBody); } else { methods.scrollToSect(htmlBody); } } } // End the Methods/Functions $.fn.pageScroller = function (methods) { this.click(function (e) { sectID = $(this).attr('id'); e.preventDefault(); // Undefined Error methods.goToID(sectID); // Call the goToID function and pass the sectID variable $(this).parent().addClass('current').prev().removeClass('current'); $(this).parent().addClass('current').next().removeClass('current'); }); $(document).keydown(function (e) { //To Do Re Use the methods/functions here }); }; })(jQuery);