assets/javascripts/materialize/forms.js in materialize-sass-1.0.0.alpha2 vs assets/javascripts/materialize/forms.js in materialize-sass-1.0.0.alpha3
- old
+ new
@@ -37,10 +37,15 @@
}
}
};
M.textareaAutoResize = function ($textarea) {
+ // Wrap if native element
+ if ($textarea instanceof Element) {
+ $textarea = $($textarea);
+ }
+
// Textarea Auto Resize
var hiddenDiv = $('.hiddendiv').first();
if (!hiddenDiv.length) {
hiddenDiv = $('<div class="hiddendiv common"></div>');
$('body').append(hiddenDiv);
@@ -202,14 +207,15 @@
var text_area_selector = '.materialize-textarea';
$(text_area_selector).each(function () {
var $textarea = $(this);
/**
- * Instead of resizing textarea on document load,
- * store the original height and the original length
+ * Resize textarea on document load after storing
+ * the original height and the original length
*/
$textarea.data('original-height', $textarea.height());
$textarea.data('previous-length', this.value.length);
+ M.textareaAutoResize($textarea);
});
$(document).on('keyup', text_area_selector, function () {
M.textareaAutoResize($(this));
});