MCPcopy Index your code
hub / github.com/json-editor/json-editor / _createAddRowButton

Method _createAddRowButton

src/editors/array.js:747–776  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

745 }
746
747 _createAddRowButton () {
748 const button = this.getButton(this.getItemTitle(), 'add', 'button_add_row_title', [this.getItemTitle()])
749 button.classList.add('json-editor-btntype-add')
750 button.addEventListener('click', (e) => {
751 e.preventDefault()
752 e.stopPropagation()
753 const i = this.rows.length
754 let editor
755 if (this.row_cache[i]) {
756 editor = this.rows[i] = this.row_cache[i]
757 this.rows[i].setValue(this.rows[i].getDefault(), true)
758 // override cached value, so optional properties are not checked.
759 if (typeof this.rows[i].deactivateNonRequiredProperties === 'function') {
760 this.rows[i].deactivateNonRequiredProperties(true)
761 }
762 this.rows[i].container.style.display = ''
763 if (this.rows[i].tab) this.rows[i].tab.style.display = ''
764 this.rows[i].register()
765 } else {
766 editor = this.addRow()
767 }
768 this.active_tab = this.rows[i].tab
769 this.refreshTabs()
770 this.refreshValue()
771 this.onChange(true)
772 this.jsoneditor.trigger('addRow', editor)
773 })
774 this.controls.appendChild(button)
775 return button
776 }
777
778 _createDeleteLastRowButton () {
779 const button = this.getButton('button_delete_last', 'subtract', 'button_delete_last_title', [this.getItemTitle()])

Callers 1

addControlsMethod · 0.95

Calls 12

getItemTitleMethod · 0.95
addRowMethod · 0.95
refreshTabsMethod · 0.95
refreshValueMethod · 0.95
addMethod · 0.80
getDefaultMethod · 0.80
triggerMethod · 0.80
getButtonMethod · 0.45
setValueMethod · 0.45
registerMethod · 0.45
onChangeMethod · 0.45

Tested by

no test coverage detected