Skip to content

Commit

Permalink
Merge pull request #95 from Icinga/fix/onclick
Browse files Browse the repository at this point in the history
Move onclick action to module.js
  • Loading branch information
martialblog authored Nov 14, 2024
2 parents 5531a2b + ddf64c2 commit 5d190a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion application/forms/EditForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ public function createElements(array $formData)
'ignore' => true,
'label' => $this->translate('Delete config'),
'class' => 'btn-remove',
'onclick' => 'return confirm("' . $this->translate('Confirm deletion') . '")',
'decorators' => ['ViewHelper']
]
);
Expand Down
9 changes: 9 additions & 0 deletions public/js/module.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
;(function (Icinga) {

'use strict';

var Toplevelview = function (module) {
this.module = module;
this.initialize();
Expand All @@ -9,6 +11,7 @@
initialize: function () {
this.module.on('click', '.tlv-view-tree .tlv-tree-node', this.processTreeNodeClick);
this.module.on('click', 'div[href].action', this.buttonClick, this);
this.module.on('click', '.btn-remove', this.onRemoveClick, this);
this.module.on('rendered', this.rendered);
},

Expand Down Expand Up @@ -53,6 +56,11 @@
$el.find('.tlv-view-tree .tlv-tree-node.tlv-collapsible.ok').addClass('tlv-collapsed');
},

onRemoveClick: function (event) {
event.stopPropagation();
return confirm('Confirm deletion?')
},

buttonClick: function (event) {
event.stopPropagation();
var $el = $(event.currentTarget);
Expand All @@ -64,4 +72,5 @@
};

Icinga.availableModules.toplevelview = Toplevelview;

}(Icinga));

0 comments on commit 5d190a4

Please sign in to comment.