twitter-bootstrap x-editable(twitter bootstrap):如何更改空值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19494605/
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 18:55:45  来源:igfitidea点击:

x-editable (twitter bootstrap): how to change the empty value?

twitter-bootstrapx-editable

提问by I. YOCK

I'm using the x-editable plug-in to have in-place edits and it works well.

我正在使用 x-editable 插件进行就地编辑,并且效果很好。

The following jsfiddle shows an example from their documentation: http://jsfiddle.net/ibrahima_yock/CFNXM/27/

以下 jsfiddle 显示了他们文档中的一个示例:http: //jsfiddle.net/ibrahima_yock/CFNXM/27/

<div>
     <span>Status:</span>
     <a href="#" id="status"></a>
</div>

.

.

//make status editable
$('#status').editable({
    type: 'select',
    title: 'Select status',
    placement: 'right',
    source: [
        {value: 1, text: 'status 1'},
        {value: 2, text: 'status 2'},
        {value: 3, text: 'status 3'}
    ]
 });

As you can see in the jsFiddle, in the html pane the status is "empty" (written in red). We'd like to translate that word into another language. How can we specify it?

正如您在 jsFiddle 中看到的,在 html 窗格中,状态为“空”(以红色书写)。我们想把这个词翻译成另一种语言。我们如何指定它?

回答by Saran

You just add this option when setting up the field:

您只需在设置字段时添加此选项:

emptytext: 'Leer', // default is 'Empty'

Fiddle: http://jsfiddle.net/Saran/hdVYS/

小提琴:http: //jsfiddle.net/Saran/hdVYS/

You can find other options in the documentation.

您可以在文档中找到其他选项。

回答by Jonathan Lidbeck

For those who prefer to use attributes, data-emptytextis another way to accomplish this:

对于那些喜欢使用属性的人,这data-emptytext是实现此目的的另一种方法:

<a href='#' id='status' 
    data-placeholder='This text appears when editing' 
    data-emptytext='This text appears when field is empty'> </a>

回答by stenly

@Saran negative, there is method "toggleDisabled" (bootstrap-editable.js line 1679) which turn off event click propagation. And this is my problem, when I switch it off, value is empty (i would like to see default value for "empty" value). In editable is property "handleEmpty" which clears empty value (bootstrap-editable.js line 1770) in the case that option disabled is to true and value is empty. I am trying to figure out how to rewrite this value to something else without touching library code

@Saran 否定,有一种方法“toggleDisabled”(bootstrap-editable.js 第 1679 行)可以关闭事件点击传播。这是我的问题,当我关闭它时,值为空(我想看到“空”值的默认值)。在 editable 中是属性“handleEmpty”,它在禁用选项为 true 且值为空的情况下清除空值(bootstrap-editable.js 第 1770 行)。我想弄清楚如何在不触及库代码的情况下将此值重写为其他值