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

Reinitialize the javascript methods #98

Open
buttflattery opened this issue Jan 7, 2020 · 2 comments
Open

Reinitialize the javascript methods #98

buttflattery opened this issue Jan 7, 2020 · 2 comments

Comments

@buttflattery
Copy link

buttflattery commented Jan 7, 2020

I am using the comments widget with yii2-scrollpager where i am loading the comments using the load more button, the problem is that the delete,reply cancel-reply buttons that call the javascript methods defined in the init() method of the js/comments.js are not binded with the newer elements is there any option to initialize them? as i cant find any

what i am doing is below

i have a view where i am calling a ListView with yii-scrollpager enabled and the view used for the ListView is _latest-bongy which has the yii2-comments widget see below

<?php
    Pjax::begin([
        'options' => [
            'id' => 'bongy',
        ],
        'enablePushState' => false,
    ]);
    echo ListView::widget([
        'dataProvider' => $bongyProvider,
        'itemView' => '_latest-bongy',
        'emptyText' => Yii::t('app', 'No bongy found'),
        'viewParams' => [
            'feelings' => $feelings,
            'comments'=>true
        ],
        'itemOptions' => [
            'class' => 'tweet-wrap',
        ],
        'options' => [
            'id' => 'list-wrapper',
        ],
        'pager' => [
            'class' => ScrollPager::class,
            'container' => '#list-wrapper',
            // 'negativeMargin' => 200,
            'item' => '.tweet-wrap',
            'paginationSelector' => '#list-wrapper>ul.pagination',
            'next' => '#list-wrapper>ul.pagination li.next a',
            'historyPrev' => '#list-wrapper>ul.pagination li.prev>a',
            'noneLeftText' => Yii::t('app', 'No more Bongies to display.'),
            'noneLeftTemplate' => '<div class="no-more"><span>{text}</span></div>',
            'triggerText' => Yii::t('app', 'Load More Bongies'),
            'triggerTemplate' => '<div class="load-more"><a href="javascript:void(0)"><i class="icon-spinner"></i>&nbsp;{text}</a></div>',
            'enabledExtensions' => [
                \kop\y2sp\ScrollPager::EXTENSION_TRIGGER,
                \kop\y2sp\ScrollPager::EXTENSION_SPINNER,
                \kop\y2sp\ScrollPager::EXTENSION_NONE_LEFT,
                \kop\y2sp\ScrollPager::EXTENSION_PAGING,
            ],
        ],
    ]);
    Pjax::end();
?>

_latest-bongy.php

i am only including the widget part from the view as the rest of the html is not relevant

echo Comment::widget(
              [
                  'model' => $model,
                  'maxLevel' => 3,
                  'formId' => "comment-form{$model->id}",
                  'pjaxContainerId' => "unique-pjax-container-{$model->id}",
                  'commentView' => '@app/views/user/comments/comment',
                  'dataProviderConfig' => [
                      'pagination' => [
                          'pageSize' => 3,
                          'pageParam' => 'comment-page',
                          'pageSizeParam' => 'comment-page-size',
                      ],
                  ],
                  'listViewConfig' => [
                      'emptyText' => Yii::t('app', 'No comments found.'),

                  ],
              ]
          );
@ahmadfadlydziljalal
Copy link

Hi, Have you managed to solve the problem above?

If yes, please share the information

@sardjn
Copy link

sardjn commented Mar 8, 2024

Please share the solution, if you managed to find it yet. Thanks

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

3 participants