X-可编辑和 Bootstrap 4
X-Editable and Bootstrap 4
之前我已经使用 X-Editable 和 Bootstrap 3 实现了内联编辑。使用 Bootstrap 4 它似乎不再有效。 Check out the JsFiddle here.
如果我像这样定义一个简单的弹出窗口:
<div style="margin: 150px">
<a href="#" class="comment" data-name="comment" data-type="text" data-pk="@item.Id" data-url="/" data-title="Enter comment">comment</a>
</div>
<script>
$(document).ready(function() {
$('.comment').editable();
});
</script>
它在 BS3 中工作正常,但一旦我切换到 BS4,它就不再工作并给出错误:
Uncaught TypeError: Cannot read property 'addClass' of undefined
at Popup.show (bootstrap-editable.js:1091)
at Editable.show (bootstrap-editable.js:1802)
at Editable.toggle (bootstrap-editable.js:1824)
at Editable.<anonymous> (bootstrap-editable.js:1547)
at HTMLAnchorElement.e (jquery-3.2.1.slim.min.js:2)
在控制台中。
我做错了什么?我应该使用不同的 library/fork 吗?
这似乎是 bootstrap 4 中的错误。
Bootstrap 4 目前处于测试版。
检查下方 link:
https://github.com/vitalets/x-editable/issues/950
为了帮助遇到此问题的其他人,以下是我的处理方式。我切换到内联模式:
$(document).ready(function() {
$('.comment').editable({
mode: 'inline',
});
$('.hours').editable({
mode: 'inline',
type: 'number',
step: '1.00',
min: '0.00',
max: '24'
});
});
这工作正常,但由于不再支持字形图标,按钮不会呈现任何图像。
我添加了 font-awesome,然后使用以下 css 恢复了图标:
.glyphicon-ok:before {
content: "\f00c";
}
.glyphicon-remove:before {
content: "\f00d";
}
.glyphicon {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
一切似乎都像以前一样工作。感谢 Sadhu 为我指明了正确的方向。
有一个新版本支持 Bootstrap 4:
https://github.com/Talv/x-editable/tree/develop/dist/bootstrap4-editable
Bootstrap 4 个使用 FontAwesome 4 的示例 https://jsfiddle.net/frallain/h5qmord2/
并在 https://jsfiddle.net/frallain/atwb19dz/
处使用 FontAwesome 5
顺便说一句,CSS before
关键字需要双 :
.glyphicon-ok::before {
content: "\f00c";
}
.glyphicon-remove::before {
content: "\f00d";
}
.glyphicon {
font-family: 'Font Awesome 5 Free';
font-weight: 900;
font-style: normal;
}
这是另一个使 x-editable 与 Bootstrap 4
兼容的示例
https://bbbootstrap.com/snippets/edit-forms-inline-using-x-editable-editor-11973728
从css开始,你可以拿走第69行以下的所有东西.form-group label {...
对于javascript部分,您可以在文档加载中复制以下内容
$.fn.editable.defaults.mode = 'inline';
$.fn.editableform.buttons =
'<button type="submit" class="btn btn-primary btn-sm editable-submit">' +
'<i class="fa fa-fw fa-check"></i>' +
'</button>' +
'<button type="button" class="btn btn-warning btn-sm editable-cancel">' +
'<i class="fa fa-fw fa-times"></i>' +
'</button>';
除了基本的 x-editable 依赖项,您还需要 FontAwesome。
之前我已经使用 X-Editable 和 Bootstrap 3 实现了内联编辑。使用 Bootstrap 4 它似乎不再有效。 Check out the JsFiddle here.
如果我像这样定义一个简单的弹出窗口:
<div style="margin: 150px">
<a href="#" class="comment" data-name="comment" data-type="text" data-pk="@item.Id" data-url="/" data-title="Enter comment">comment</a>
</div>
<script>
$(document).ready(function() {
$('.comment').editable();
});
</script>
它在 BS3 中工作正常,但一旦我切换到 BS4,它就不再工作并给出错误:
Uncaught TypeError: Cannot read property 'addClass' of undefined
at Popup.show (bootstrap-editable.js:1091)
at Editable.show (bootstrap-editable.js:1802)
at Editable.toggle (bootstrap-editable.js:1824)
at Editable.<anonymous> (bootstrap-editable.js:1547)
at HTMLAnchorElement.e (jquery-3.2.1.slim.min.js:2)
在控制台中。
我做错了什么?我应该使用不同的 library/fork 吗?
这似乎是 bootstrap 4 中的错误。 Bootstrap 4 目前处于测试版。
检查下方 link: https://github.com/vitalets/x-editable/issues/950
为了帮助遇到此问题的其他人,以下是我的处理方式。我切换到内联模式:
$(document).ready(function() {
$('.comment').editable({
mode: 'inline',
});
$('.hours').editable({
mode: 'inline',
type: 'number',
step: '1.00',
min: '0.00',
max: '24'
});
});
这工作正常,但由于不再支持字形图标,按钮不会呈现任何图像。
我添加了 font-awesome,然后使用以下 css 恢复了图标:
.glyphicon-ok:before {
content: "\f00c";
}
.glyphicon-remove:before {
content: "\f00d";
}
.glyphicon {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
一切似乎都像以前一样工作。感谢 Sadhu 为我指明了正确的方向。
有一个新版本支持 Bootstrap 4:
https://github.com/Talv/x-editable/tree/develop/dist/bootstrap4-editable
Bootstrap 4 个使用 FontAwesome 4 的示例 https://jsfiddle.net/frallain/h5qmord2/ 并在 https://jsfiddle.net/frallain/atwb19dz/
处使用 FontAwesome 5顺便说一句,CSS before
关键字需要双 :
.glyphicon-ok::before {
content: "\f00c";
}
.glyphicon-remove::before {
content: "\f00d";
}
.glyphicon {
font-family: 'Font Awesome 5 Free';
font-weight: 900;
font-style: normal;
}
这是另一个使 x-editable 与 Bootstrap 4
兼容的示例https://bbbootstrap.com/snippets/edit-forms-inline-using-x-editable-editor-11973728
从css开始,你可以拿走第69行以下的所有东西.form-group label {...
对于javascript部分,您可以在文档加载中复制以下内容
$.fn.editable.defaults.mode = 'inline';
$.fn.editableform.buttons =
'<button type="submit" class="btn btn-primary btn-sm editable-submit">' +
'<i class="fa fa-fw fa-check"></i>' +
'</button>' +
'<button type="button" class="btn btn-warning btn-sm editable-cancel">' +
'<i class="fa fa-fw fa-times"></i>' +
'</button>';
除了基本的 x-editable 依赖项,您还需要 FontAwesome。