How to pass variables into dynamic UIkit Modal?
<p>How do i pass variables into a UIkit Modal?</p>

<p>The Button:</p>

<pre><code>&lt;button type="button" class="uk-button" data-uk-modal="{target:'#info',center:true}" data-added="added-test" data-modified="modified-test"&gt;&lt;i class="uk-icon-info"&gt;&lt;/i&gt;&lt;/button&gt;
</code></pre>

<p>The Modal:</p>

<pre><code>&lt;div class="uk-modal" id="info"&gt;
    &lt;div class="uk-modal-dialog"&gt;
        &lt;h4 style="margin-bottom:5px;"&gt;Added:&lt;/h4&gt;
        &lt;div id="added"&gt;&lt;/div&gt;&lt;br&gt;
        &lt;h4 style="margin-bottom:5px;"&gt;Modified:&lt;/h4&gt;    
        &lt;div id="modified"&gt;&lt;/div&gt;
        &lt;div class="uk-modal-footer"&gt;
          &lt;button type="button" class="uk-button uk-modal-close"&gt;Close&lt;/button&gt;        
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>The Script:</p>

<pre><code>$(document).ready(function () {
    $('#info').on('uk.modal.show', function (event) {
        var button = $(event.relatedTarget);
        var added = button.data('added');
        var modified = $(e.target).data('modified');
        var modal = $(this);
        modal.find('.uk-modal-dialog #added').text(added);
        modal.find('.uk-modal-dialog #modified').text(modified);
    });
});
</code></pre>

<p>This is not working. I do not get a error in the console. I´ve already tried a few other ways but all of them didn´t worked as they should.</p>

<p><strong>Update #1</strong></p>

<p>The following jquery works partially. I´ve added the id "infotrigger" to the button.</p>

<pre><code>jQuery('#info').appendTo("body");
jQuery(document).on('click', '#infotrigger', infomodal_handler);
function infomodal_handler(e)
{
    var added = jQuery(e.target).data('added');
    var modified = jQuery(e.target).data('modified');
    jQuery('#info').on({
        'show.uk.modal':function(){
            jQuery('#added', jQuery(this)).text(added);
            jQuery('#modified', jQuery(this)).text(modified);
        }
    }).trigger('show.uk.modal');
}
</code></pre>

<p>The Problem now is that it´s only working partially. I think the reason is that the button is in a foreach loop. Mostly i have old data when opening the modal. If i open it again i have mostly the correct data.</p>

<p>Any ideas how to fix that?</p>