Created
December 13, 2013 17:58
-
-
Save jclement/7948373 to your computer and use it in GitHub Desktop.
Firefox automatically adds a "bonus" row to textarea fields making them taller than they should be given the "row=X" attribute on the text area. This is really annoying when you want the textarea to simply be 1 row high and to have it automatically grow, as needed, with jquery-autosize. The following snippet forces a starting height on the contr…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (navigator.userAgent.toLowerCase().indexOf("firefox") !== -1) { | |
| // Firefox/Mozilla automatically adds a "bonus" row to textareas. Through CSS, force the height back to the number of rows specified before | |
| // autosize sees it. | |
| var height = parseFloat(input.css("line-height")) * opt.rows + parseFloat(input.css("padding-top")) + parseFloat(input.css("padding-bottom")); | |
| input.css("height", height + "px"); | |
| } | |
| _.defer(function() { | |
| input.autosize(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment