0

I'm working on a component where I'm trying to add a popup using Semantic UI popup, and it's working as expected. But after ajax load it's not working.

Here part of the code code -

<script type="text/javascript">
    jQuery(document).ready(function($){

        $('.trigger').popup({
            inline     : true,
            hoverable  : true,
            position   : 'bottom right',
            delay: {
                show: 300,
                hide: 800
            },
            selector    : {
                popup    : '.popup'
            }
        });

    });

window.Oby.registerAjax(<?php echo $events; ?>, function(params) {
    var o = window.Oby, el = document.getElementById('content');
    if(!el) return;
    o.addClass(el, "active");
    o.xRequest("<?php echo $url, true, false, true); ?>", {update: el}, function(xhr){
        o.removeClass(el, "active");
    });
});
</script>

What can I do so it will still work after ajax content refresh/load?

Russell
  • 45
  • 9
  • `jQuery.ready()` refers to document `ready` event, which fires only once. After the entire DOM tree has been parsed, before the window `load` event. If you want to run code after a successful ajax call, you should place it inside the `done` event of the `ajax` call. – tao May 03 '17 at 20:38
  • can you show me an example? – Russell May 03 '17 at 20:52
  • Of course: http://api.jquery.com/jquery.ajax/ – tao May 03 '17 at 20:58
  • I tried, but it's not working. – Russell May 03 '17 at 21:10
  • @Sifur show what you tried, and describe what goes wrong ("not working" is not an adequate description). – ADyson May 03 '17 at 21:47
  • Possible duplicate of [Does AJAX loaded content get a "document.ready"?](http://stackoverflow.com/questions/20246299/does-ajax-loaded-content-get-a-document-ready) – Fabian Horlacher May 03 '17 at 21:50

0 Answers0