简体   繁体   中英

Call function from outside jquery plugin - slimscroll.js

The code for the plugin is as follows,

(function($) {
    jQuery.fn.extend({
          slimScroll: function(options) {
            var defaults = {
              ....
            };

            this.each(function() {
                function scrollContent(y, isWheel, isJump) {
                  ....
                }
              }
              return this;
            }
          }); jQuery.fn.extend({
          slimscroll: jQuery.fn.slimScroll
        });

How do i call the function scrollContent() from outside the plugin?

i have tried

$("#myId").Slimscroll().ScrollContent();

$("#myId").data("SlimScroll").ScrollContent();

And many other ways but dosent seem to get it working.

As the code shows scrollContent is a private method and is not supposed to be accessed from outside the plugin. Instead you could re-render the scrollbar by simply calling $("#myId").slimScroll() as shown in this example .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM