Page 1 of 1

better way of solving autoresizing wymeditor window?

PostPosted: Tue Oct 20, 2009 10:12 pm
by furtivefelon
Hi all, I recently came up with a pretty crude hack to auto grow the wymeditor window as the content becomes longer, here is a simple version assuming everything is default:

Code: Select all
setInterval(function(){
   outter = $('iframe');
   inner = $('iframe').contents().find('body');
   if(outter.height() < inner.height() + 10){
      outter.height(outter.height()+50);
   }
}, 100);


Ideally it would work as needed, not based on a timer. For example, when a enter key is pressed, it would check whether the height grown or not, and act accordingly, similarly binding to all other events (ideally it would just be on change, which jquery has such an event, not sure how to go about using that).

Anyone have any idea how to accomplish my ideallys?

Thanks a lot!

Re: better way of solving autoresizing wymeditor window?

PostPosted: Tue Oct 27, 2009 11:24 pm
by mr_lundis
Hello!
The jQuery change event wont work as the editor area aren't really a form field but an iframe. Listening to any key event should work fine though, as long as you listen inside the iframe as event occuring inside the iframe won't bubble up outside the iframe document (i.e. to the parent document).

Cheers! ;)

Re: better way of solving autoresizing wymeditor window?

PostPosted: Tue May 18, 2010 8:51 am
by christracy123
Wow this is great!! Hmmm thanks for the codes furtivefelon!!

Re: better way of solving autoresizing wymeditor window?

PostPosted: Fri Jun 11, 2010 9:52 am
by arkiller
Great code, but has bugs. If the iframe grows up to x, it goes out of the main div. And if you erase code after growing the iframe it doesnt turn smaller. If you fix this, this code will be usable!!
If you do, share with us!!