jQuery Autosize plugin error - intermediate value(…) is not a function

前端 未结 3 1914
执笔经年
执笔经年 2020-12-23 21:43

I use jQuery Autosize plugin:

http://www.jacklmoore.com/autosize/

The script itself you can see here:

http://www.jacklmoore.com/js/jquery.autosize.js

相关标签:
3条回答
  • 2020-12-23 21:51

    You may have declared a function, inside a function, after you needed it. This was my problem.

    0 讨论(0)
  • 2020-12-23 22:09

    FWIW the autosize invocation method has changed. If you end up here and are using it with jQuery

    Previously it was

    $('textarea').autosize();
    

    The new invocation is

    autosize($('textarea'));
    
    0 讨论(0)
  • 2020-12-23 22:13

    the "TypeError: (intermediate value)(...) is not a function" pops up as the result of missing a semi colon on the function BEFORE the one it throws an error on. It might be as simple as:

    jQuery(function($){$(document).ready(function(){
    $('textarea').autosize();
    }  
    ); //<-----
    

    or it could be the function declared before that. An example of how this is cause is in this code:

    var populate = function(sw) {
      myglobalswitch = sw;
      window.setTimeout(repopulate, 250, sw);
    }
    
    (function( $ ) {
    $.widget( "custom.combobox", {
    _create: function() {
    ....
    })( jQuery );
    

    results in the Intermediate value is not... on the last line: })( jQuery );

    However, the fix is adding a semi colon to the populate function:

    var populate = function(sw) {
      myglobalswitch = sw;
      window.setTimeout(repopulate, 250, sw);
    }  ;
    

    to prevent the parser from thinking that "var populate = ... " and (function($) ... are a single statement, the second extending from the first.

    0 讨论(0)
提交回复
热议问题