プラグイン内に複数の関数を呼び出したいのですが、何らかの理由でメソッド undefinedを取得します。
メソッドを使用して関数をラップしないと、
関数ステートメントには名前が必要です
- ここで何が間違っていますか?
関数をメソッド 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);