admin管理员组文章数量:1387447
My objective: Allowing inline-edition of a description with the jquery plugin jeditable.
My problem: The textarea input is bigger than the original div, leading to the apparition of scroll-bars.
Attempted solution:
$('.editableDescription').editable('/', {
id: 'data[Chantier][id]',
name: 'data[Chantier][Description]',
type: 'textarea',
height: $(".editableDescription").height() + "px",
width: $(".editableDescription").width()+ "px",
onblur: 'submit',
tooltip: ''
});
I tried to take the size of the wrapper div with jquery, but it still fails!
jsFiddle:jsFiddle
My objective: Allowing inline-edition of a description with the jquery plugin jeditable.
My problem: The textarea input is bigger than the original div, leading to the apparition of scroll-bars.
Attempted solution:
$('.editableDescription').editable('http://jsfiddle/echo/jsonp/', {
id: 'data[Chantier][id]',
name: 'data[Chantier][Description]',
type: 'textarea',
height: $(".editableDescription").height() + "px",
width: $(".editableDescription").width()+ "px",
onblur: 'submit',
tooltip: ''
});
I tried to take the size of the wrapper div with jquery, but it still fails!
jsFiddle:jsFiddle
Share Improve this question asked Aug 14, 2012 at 8:18 L. SannaL. Sanna 6,5627 gold badges35 silver badges47 bronze badges2 Answers
Reset to default 6First, you need to remove height:250px;
from .longtext
, or else Jeditable will take it as the default height for the <textarea>
.
Then I made sure that .longtext
had the same styles as the <textarea>
that will be nested inside it, such as line-height, font-size, font-family
.
And I assumed that you'll probably have more than one .longtext
in your document, so you will need to apply different heights
to different <textarea>s
. So I changed this:
$('.editableDescription').editable('http://jsfiddle/echo/jsonp/',
{
id : 'data[Chantier][id]',
name : 'data[Chantier][Description]',
type : 'textarea',
height:($(".editableDescription").height()) + "px",
width: ($(".editableDescription").width()) + "px",
onblur: 'submit',
tooltip : ''
});
to this:
$('.editableDescription').each(function()
{
$(this).editable('http://jsfiddle/echo/jsonp/',
{
id:'data[Chantier][id]',
name:'data[Chantier][Description]',
type:'textarea',
height:$(this).height()+'px',
/* here it will take the height of the currently active .longtext */
width:$(this).width()+'px',
onblur:'submit',
tooltip: ''
});
});
DEMO
And that's basically it.
You may try to set the CSS overflow property to hidden
本文标签: javascriptcontrolling the size of textarea with jeditableStack Overflow
版权声明:本文标题:javascript - controlling the size of textarea with jeditable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744503918a2609478.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论