0

I'm creating simple jquery library, actually I just learn about creating my own library with jQuery, I need to access variable inside lib function from outside main function. Here short code, I want to access variable page and loading from $.fn.beyondScroll.reset function. How I accomplish this task? I have tried to access via $.fn.beyondScroll.page; but it return undefinded. Thanks.

(function ($) {

    $.fn.beyondScroll = function (options) {
        var settings = $.extend({}, $.fn.beyondScroll.defaults, options);

        var complete = false; // need access this variable
        var page = 1;

        return this.each(function () {
            var loading = false; // and this variable
        });
    };

    $.fn.beyondScroll.reset = function(){
        // access those variables from here
        var currentPage = $.fn.beyondScroll.page; // return undefined
    }
}(jQuery));
Angga Ari Wijaya
  • 1,759
  • 1
  • 15
  • 31
  • Please take a look in this link: [http://stackoverflow.com/questions/1034306/public-functions-from-within-a-jquery-plugin](http://stackoverflow.com/questions/1034306/public-functions-from-within-a-jquery-plugin) – Anusha_Systematix Nov 23 '16 at 07:12
  • after read that SO question, I implement another approach about public function, and it works like charm,, thanks.. – Angga Ari Wijaya Nov 23 '16 at 08:35

0 Answers0