Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize ajax.org ACE editor based on browser's size

Tags:

ace-editor

I want to let the ACE editor to be resizable based on the browser's size. however, the editor element must be explicitly sized in order to be initialized by the ace editor's API.

The editor works when I set the width:100%/height:400px. Having this setting allows the editor 's width responsive to the browser's width. However, not responsive for the editor's height.

Is there a way to make the editor's size more flexible by responding to browser's size?

Thanks

like image 213
Kata Avatar asked Apr 13 '12 03:04

Kata


2 Answers

function resizeAce() {
  return $('#editor').height($(window).height());
};
//listen for changes
$(window).resize(resizeAce);
//set initially
resizeAce();
like image 71
jpillora Avatar answered Sep 26 '22 01:09

jpillora


set position:absolute;top:0; bottom:0 like https://github.com/ajaxorg/ace-builds/blob/master/editor.html#L14

like image 33
a user Avatar answered Sep 26 '22 01:09

a user