diff --git a/src/bootstrap-table.js b/src/bootstrap-table.js
index 0b95a258a9..e3f535e2ef 100644
--- a/src/bootstrap-table.js
+++ b/src/bootstrap-table.js
@@ -608,6 +608,51 @@ class BootstrapTable {
this.initBody()
}
+ renderButton (buttonName, buttonConfig) {
+ let buttonHtml
+
+ if (buttonConfig.hasOwnProperty('html')) {
+ if (typeof buttonConfig.html === 'function') {
+ buttonHtml = buttonConfig.html()
+ } else if (typeof buttonConfig.html === 'string') {
+ buttonHtml = buttonConfig.html
+ }
+ } else {
+ let buttonClass = this.constants.buttonsClass
+
+ if (buttonConfig.hasOwnProperty('attributes') && buttonConfig.attributes.class) {
+ buttonClass += ` ${buttonConfig.attributes.class}`
+ }
+ buttonHtml = `'
+ }
+ return buttonHtml
+ }
+
initToolbar () {
const opts = this.options
let html = []
@@ -751,49 +796,7 @@ class BootstrapTable {
const buttonsHtml = {}
for (const [buttonName, buttonConfig] of Object.entries(this.buttons)) {
- let buttonHtml
-
- if (buttonConfig.hasOwnProperty('html')) {
- if (typeof buttonConfig.html === 'function') {
- buttonHtml = buttonConfig.html()
- } else if (typeof buttonConfig.html === 'string') {
- buttonHtml = buttonConfig.html
- }
- } else {
- let buttonClass = this.constants.buttonsClass
-
- if (buttonConfig.hasOwnProperty('attributes') && buttonConfig.attributes.class) {
- buttonClass += ` ${buttonConfig.attributes.class}`
- }
- buttonHtml = `'
- }
-
- buttonsHtml[buttonName] = buttonHtml
+ buttonsHtml[buttonName] = renderButton(buttonName, buttonConfig)
const optionName = `show${buttonName.charAt(0).toUpperCase()}${buttonName.substring(1)}`
const showOption = opts[optionName]