Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ahmadfadlydziljalal opened this issue Mar 19, 2023 · 0 comments
Open

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

ahmadfadlydziljalal opened this issue Mar 19, 2023 · 0 comments

Comments

@ahmadfadlydziljalal
Copy link

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant