twitter-bootstrap 以引导程序 x 可编辑形式设置最大长度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15572619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 16:42:08  来源:igfitidea点击:

Setting max length in bootstrap x-editable form

jquerycsstwitter-bootstrap

提问by user2091275

I need to set max length for the text box in the bootstrap xeditable form.The thing is that the textbox which appears is an in build feature of the form so i could not set maxlength as an html attribute.I tried it using jquery but its not working out.( I am not able to attach the screenshot) Please help me to solve this,

我需要在 bootstrap xeditable 表单中为文本框设置最大长度。问题是出现的文本框是表单的构建功能,所以我无法将 maxlength 设置为 html 属性。我尝试使用 jquery 但它不工作。(我无法附上屏幕截图)请帮我解决这个问题,

回答by Einar

You can set HTML attributes by overwriting the template:

您可以通过覆盖模板来设置 HTML 属性:

Such as:

如:

$('#your_id').editable({
  tpl: '<textarea maxlength="250"></textarea>'
});

回答by Marijn

Well, you should be able to set the maxLengthattribute using jQuery, for instance like this:

好吧,您应该能够maxLength使用 jQuery设置属性,例如:

$('#myBox').attr('maxlength', 6);

There is some more information in this question.

这个问题中有更多信息。

But it is hard to tell from your question what you have tried. Please add the jQuery code you tried to your question, so we can better help you.

但是很难从您的问题中看出您尝试了什么。请将您尝试的 jQuery 代码添加到您的问题中,以便我们更好地帮助您。

回答by Shai

Looks like there's a "inputclass" attribute you can pass so you can style it how you want to. Overriding tpl option might be hairy because there are custom library classes applied to it.

看起来你可以传递一个“inputclass”属性,这样你就可以按照你想要的方式设置它的样式。覆盖 tpl 选项可能很麻烦,因为有应用到它的自定义库类。