Skip to content

Collaboration with https://docs.infiniteajaxscroll.com/ #111

@ahmadfadlydziljalal

Description

@ahmadfadlydziljalal

WIth this Yii2 component, https://bitbucket.org/ereminmdev/yii2-infinite-scroll/src/master/, I got the re-initialization still failed.
Can you provide a comment of the following code ?

For now, the comment is redirect to something like: http://localhost/comment/default/create?entity=x---

$JS = <<<JS

jQuery.ias().on("rendered", function(elements) {
    
    let pjaxContainer;
    let pjaxContainerId;
    
    let form;
    let formId;
 
    jQuery.each(elements, function(key, element){
    
        pjaxContainer = jQuery(element).find('div').closest('.comment-wrapper');
        pjaxContainerId = '#' + pjaxContainer.children().first().attr('id');
        
        form = jQuery(element).find('div').closest('form');
        formId = '#' + form.attr('id');
        
        jQuery.pjax.reload({
            container: pjaxContainerId, 
            timeout: 1000000, 
            scrollTo: false, 
            url: window.location.href
        }).done(function() {
            jQuery(formId).comment('init', {
                pjaxContainerId: pjaxContainerId
            });
        });
    
    });

});

jQuery(document).on('pjax:complete', function(event) {
    console.log(event.target);   
});
JS;

$this->registerJs($JS);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions