Search code examples
javascriptjqueryprototypejscrollpane

Adding new method to JScrollPane with prototype


I'm include some libs

 <script type="text/javascript" src="js/jquery-1.7.2.js"></script>

  <!-- the mousewheel plugin - optional to provide mousewheel support -->
  <script type="text/javascript" src="js/jquery.mousewheel.js"></script>

  <!-- the jScrollPane script -->
  <script type="text/javascript" src="js/jquery.jscrollpane.js"></script>

Then want to add a new method

<script type="text/javascript"> 
    JScrollPane.prototype.putClientProperty = function(propertyName, elementId){

    ...
    };
</script>

And receive: JScrollPane is undefined. What i'm doing wrong?


Solution

  • You receive the error because JScrollPane is not a property of the window/global object but is added to jquery.prototype / jquery.fn. So, you should use:

    jquery.fn.JScrollPane.prototype.putClientProperty = function(propertyName, elementId){
    
    ...
    };