Title: Textbox - Multiline auto height Post by: jega on June 12, 2018, 01:25:28 AM Hi.
Have i missed something. Having a multiline textbox, filled with text from db. Expected that the height is set, so i can see all the text, when height:'auto' <input id="dbhPurpose" name="dbhPurpose" class="easyui-textbox" data-options=" width:400, height: 'auto', multiline:true"> Jesper Title: Re: Textbox - Multiline auto height Post by: jarry on June 12, 2018, 05:30:11 PM Please call the extended 'autoHeight' method.
Code: (function($){ function setHeight(target){ var opts = $(target).textbox('options'); $(target).next().css({ height: '', minHeight: '', maxHeight: '' }); var tb = $(target).textbox('textbox'); tb.css({ height: 'auto', minHeight: opts.minHeight, maxHeight: opts.maxHeight }); tb.css('height', 'auto'); var height = tb[0].scrollHeight; tb.css('height', height+'px'); } function autoHeight(target){ var opts = $(target).textbox('options'); var onResize = opts.onResize; opts.onResize = function(width,height){ onResize.call(this, width, height); setHeight(target); } var tb = $(target).textbox('textbox'); tb.unbind('.tb').bind('keydown.tb keyup.tb', function(e){ setHeight(target); }); setHeight(target); } $.extend($.fn.textbox.methods, { autoHeight: function(jq){ return jq.each(function(){ autoHeight(this); }) } }) })(jQuery); Code: $('#dbhPurpose').textbox('autoHeight'); Title: Re: Textbox - Multiline auto height Post by: jega on June 13, 2018, 09:57:58 AM Thanks for reply jarry
Works fine as a method. What if i want it as a property, with true/false, and default false. How could that be done?. Know how to make an extended method, but how to make an property Jesper |