surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.11k stars 801 forks source link

Survey-Vue doAfterRenderSurvey and doAfterRenderHeader throwing console errors in mounted hook #2625

Open joseph-parsley opened 3 years ago

joseph-parsley commented 3 years ago

Are you requesting a feature, reporting a bug or asking a question?

Reporting a bug or asking a question. I could be doing this wrong but I don't think so.

What is the current behavior?

When rendering the Survey Vue component, it throws an error saying this.survey.doAfterRenderHeader is not a function and this.survey.doAfterRenderSurvey is not a function. Both of these are being called in the mounted hooks of the SurveyHeader and Survey components, respectively. Everything seems to work properly (though I am not attempting to change anything after rendering the header/survey, so that might now work) otherwise.

What is the expected behavior?

No JavaScript errors in the console.

How would you reproduce the current behavior (if this is a bug)?

Mounting a Vue Survey component.

Provide the test code and the tested page URL (if applicable)

Test code

<template>
    <div>
        <b-collapse
            class="card"
            animation="slide"
            v-for="(surveySingle, index) in initializedSurveys"
            :key="index"
            :open="isOpen == index"
            @open="isOpen = index"
        >
            <template #trigger="props">
                <div class="card-header" role="button">
                    <p class="card-header-title mb-0">
                        {{ getTitleForPoll(index) }}
                    </p>
                    <a class="card-header-icon">
                        <svg-arrow-down
                            :class="{ 'rotate-180': props.isOpen }"
                        />
                    </a>
                </div>
            </template>
            <div class="card-content">
                <div class="content">
                    <survey :survey="surveySingle" />
                </div>
            </div>
        </b-collapse>
    </div>
</template>

surveySingle is a properly initialized SurveyModel and seems to work in all other respects.

Specify your

tsv2013 commented 3 years ago

Here is the codesandbox sampel - https://codesandbox.io/s/surveyjs-vue-forked-z70b5 It doesn't have any errors in console. Could you modify it to illustrate the issue?

joshcampbell191 commented 3 years ago

@joseph-parsley I just ran into this issue as well. In order to resolve it, I used Model (or VueSurveyModel) instead of SurveyModel which has the definitions to the missing functions.