Joomla media manager opens in a new window


Good day! I am writing a module for Joomla 3.43 . The module has a button " Add review ", when clicked, elements are added to the block, including the button " Add image ". After adding elements to the block, when you click on the " Add image " button, the Media manager should open in a modal window, instead, the link is followed. But if I click on the save button and then click " Add Image " then the manager will open in a modal window. Although after saving the module data, the elements are added in the same way. Here is the code:

function addComment(el){
    $html = '';
    var n = 'list'+i;'selectlist').innerHTML += '<a class="modal btn" href="index.php?option=com_media&view=images&tmpl=component&fieldid='+n+'&folder=" title="Выбрать"> Выбрать</a>'

And the button, after clicking on which the function is called

<ul class="select" id="selectlist">            	
    <a href="" class="add" onclick="addComment();return false;">Add Comment</a>

Tell me what's wrong. I don't know where to dig. Thanks in advance


Maybe it's just that your buttons are not automatically attached to the click event and the appearance of the modal window? most likely after reloading, the JS library just starts to see your buttons and everything works. That is, at the time of creation, you need not only create buttons, but also refresh your library or explicitly hang events on it.

Scroll to Top