How to use and get onclick event from Popconfirm?


Topic: How to use and get onclick event from Popconfirm?

itvis-org-au asked 2 years ago

Expected behavior

I should be able to assign onClick() to popconfirm button and it should capture the click event

Actual behavior

Since the element doesn't initially exist on the page and is created with JS after being triggered it can't be accessed with event listeners such as onClick()

Resources (screenshots, code snippets etc.)

Here is sample code to target any popconfirm OK button, but nothing happens:

$("#popconfirm-button-confirm").click(function(){

console.log($(this))

});

A sample code would be appreciated.


kpienkowska staff answered 2 years ago

The listener had to be added after popconfirm is open (button needs to exist at the moment. Example here: https://mdbootstrap.com/snippets/standard/kpienkowska/4213028


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 4.3.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No