0

I'm using the yui editor. I want to know if it possible to limit the editable height area.

ex: height:300px, so over 300px, the carret stop writting.

thanks

Frank
  • 323
  • 2
  • 16

2 Answers2

1
html:

<textarea id="countMe" cols="30" rows="5"></textarea>
<div class="theCount">Lines used: <span id="linesUsed">0</span><div>js:

$(document).ready(function(){

var lines = 10;
var linesUsed = $('#linesUsed');

$('#countMe').keydown(function(e) {

    newLines = $(this).val().split("\n").length;
    linesUsed.text(newLines);

    if(e.keyCode == 13 && newLines >= lines) {
        linesUsed.css('color', 'red');
        return false;
    }
    else {
        linesUsed.css('color', '');
    }
});

});

You can do some code on your editor panel when user enter characters & calculate length and return false if limit exceeds.

kaushik0033
  • 679
  • 6
  • 12
0

This is a simple jQuery that can work on iExplorer, Firefox and Crome:

 $('#my_frame').load(function () {  
        $(this).height($(this).contents().find("html").height()+20);
    });

I add 20 pixels just to avoid any scroll bar, but you may try a lower bound.

kaushik0033
  • 679
  • 6
  • 12
  • You dont need to limit the area? – kaushik0033 Sep 27 '13 at 16:12
  • you are setting the editable area height (iframe). I already can do this: var myConfig = { height: '200px'}; var myEditor = new YAHOO.widget.Editor('editor', myConfig); myEditor.render(); I want to limit the text in the editable area to 200px. Over 200px if you press the 'enter' key, it should return false so no other new line is created. – Frank Sep 27 '13 at 16:15
  • In other words, if I have an editable area of 200 px (height), I ONLY want this area for editing text. (no scrolling, no new line, no overflow) – Frank Sep 27 '13 at 16:49