yii2mod / yii2-comments

Comments module for Yii2
MIT License
158 stars 63 forks source link

jquery.pjax.js:233 Uncaught TypeError: Cannot read property 'type' of undefined #80

Closed bahrammzm closed 6 years ago

bahrammzm commented 6 years ago

I have used kartik/treemanager extension model for this extension . Everything work as well for initial node , but when i change the node of tree and after that submit the comment , comment button stuck in "loading..." and shows the below error . although comment saved in database .

capture

ihorchepurnyi commented 6 years ago

I don't have time to fix this issue now and I never used this extension with kartik/treemanager. Can you fix this issue and submit PR for this issue?

bahrammzm commented 6 years ago

How can disable pjax for form submit at all?

ihorchepurnyi commented 6 years ago

You need to create own view and override this property for Comment widget

bahrammzm commented 6 years ago

i found the solution . 1- set a Flash message in actionCreate in DefaultController that store $commentModel->entityId value
Yii::$app->session->setFlash('commentSaved', $commentModel->entityId); 2- set displayValue property in kartik/treemanager with that Flash message
'displayValue' => (Yii::$app->session->hasFlash('commentSaved') ? Yii::$app->session->getFlash('commentSaved') : Tree::find()->min('id')), 3- replace $.pjax(pjaxSettings); to location.reload(); in comment.js , function createComment

ihorchepurnyi commented 6 years ago

Nice!