Created
June 26, 2012 13:10
-
-
Save bluerabbit/2995714 to your computer and use it in GitHub Desktop.
youRoomの書き込むテキストエリアが動的に変わればいいのに
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
| $('.entry_content').scroll(function () { | |
| var self = $(this); | |
| self.css('height', (parseInt(self.css('height').slice(0,-2)) + 10) + 'px'); | |
| }); |
Author
Author
という事でググってみたら下記のようにすればいいんじゃないの?という事だった。livequeryだったらscroll対応してたりしないのかな。
$('.entry_content').live('keyup', function() {
var el = $(this);
if (!el.data("has-scroll")) {
el.data("has-scroll", true);
el.scroll(function(){
resizeTextArea(el);
});
}
resizeTextArea(el);
});
function resizeTextArea(elem) {
elem.scrollTop(0);
elem.height(elem[0].scrollHeight - elem[0].clientHeight + elem.height());
}
Author
適当なliveとってイベント割り当てすればいいんじゃないのと言うことで下記になった。
$('.entry_content').live('focus', function () {
var self = $(this);
if (!self.data("has-scroll")) {
self.data("has-scroll", true);
self.scroll(function () {
self.css('height', (parseInt(self.css('height').slice(0,-2)) + 10) + 'px');
});
}
});
Author
scrollHeight, clientHeight, height()って複数ブラウザで互換性あるのかな?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
動的にテキストエリアを作ってるところがあるのでliveする必要があるけど、liveはscrollには効かないようだ