Guest User

Guest User

  • Tech Writer
  • 515
  • 46.4k

Regarding addEventListener event

Mar 6 2019 1:13 AM
I am using the addEventListener event on one of the buttons in MVC datatable. (I am using that button to Show image in popup corresponding to that row).
 
So when I clicked on that button in first row in datatable, it works fine. But as I go to the same button on a diferent row, it does not do anything.
 
Maybe multiple addEventListener is not working.
 
So need help in this.
 
Kindly Thank you in advance.
 
Following is code snippet :
  1. document.getElementById("buttonopenimage").addEventListener("click", ShowSnapOnHistory,false);  
  2. function ShowSnapOnHistory()  
  3. {  
  4. alert($("#hdnFlag").val());  
  5. $.ajax({  
  6. url: '@Url.Action("ShowReceiptImageInPopup", "Transaction")',  
  7. type: 'GET',  
  8. data: { Id: $("#hdnFlag").val() },  
  9. dataType: 'json',  
  10. success: function (result) {  
  11. var image = new Image();  
  12. image.src = 'https://api.shoppercoin.io/UploadedFiles/' + result.reclist.ReceiptName;  
  13. // $('#imgReceipt').attr('src', 'https://api.shoppercoin.io/UploadedFiles/' + result.reclist.ReceiptName);  
  14. var viewer = new Viewer(image,  
  15. {  
  16. hidden: function () {  
  17. viewer.destroy();  
  18. },  
  19. });  
  20. // image.click();  
  21. viewer.show();  
  22. }  
  23. });  
  24. }

Answers (3)