jQuery Autosize plugin error - intermediate value(...) is not a function
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23370269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery Autosize plugin error - intermediate value(...) is not a function
提问by user
I use jQuery Autosize plugin:
I use jQuery Autosize plugin:
http://www.Hymanlmoore.com/autosize/
http://www.Hymanlmoore.com/autosize/
The script itself you can see here:
The script itself you can see here:
http://www.Hymanlmoore.com/js/jquery.autosize.js
http://www.Hymanlmoore.com/js/jquery.autosize.js
This is how I use the script:
This is how I use the script:
jQuery(function($){$(document).ready(function(){
$('textarea').autosize();
}
Problem N 1
Problem N 1
Just updated the script to the latest version and it stopped to work:
Just updated the script to the latest version and it stopped to work:
"TypeError: (intermediate value)(...) is not a function"
Javascript console reports this error on the last line of the script:
Javascript console reports this error on the last line of the script:
}(window.jQuery || window.$));
Problem N 2
Problem N 2
Script doesn't work in modal windows (PrettyPhoto) and javascript console doesn't show any errors.
Script doesn't work in modal windows (PrettyPhoto) and javascript console doesn't show any errors.
Any ideas?
Any ideas?
回答by ppostma1
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:
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:
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 );
results in the Intermediate value is not...on the last line: })( jQuery );
However, the fix is adding a semi colon to the populate function:
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.
to prevent the parser from thinking that "var populate = ... " and (function($) ... are a single statement, the second extending from the first.
回答by engineerDave
FWIW the autosize invocation method has changed. If you end up here and are using it with jQuery
FWIW the autosize invocation method has changed. If you end up here and are using it with jQuery
Previously it was
Previously it was
$('textarea').autosize();
The new invocation is
The new invocation is
autosize($('textarea'));
回答by Ken Brockert
You may have declared a function, inside a function, after you needed it. This was my problem.
You may have declared a function, inside a function, after you needed it. This was my problem.