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.21k stars 813 forks source link

onAfterRenderSurvey HTML Element Contains KnockOut Object #3446

Open aaronsheldon opened 3 years ago

aaronsheldon commented 3 years ago

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

One very small bug report.

What is the current behavior?

The parameter options.htmlElement in the callback for onAfterRenderSurvey contains the KnockOut object.

What is the expected behavior?

The parameter options.htmlElement in the callback for onAfterRenderSurvey should contain the element that the survey was attached to.

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

Add a new callback to onAfterSurveyRender and use the parameter options.htmlElement.

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

Tested page URL: https://littlelambdas.bubbleapps.io/version-test/surveytest

Test code

// In production this is put under a more protected object than global
const mySurvey = new Survey.Model(null);

// Add the callback assumes we have the element in myJQuery
mySurvey.onAfterSurveyRender.add(
    (sender, options) => {
        console.log("is");
        console.log(JSON.stringify(options.htmlElement, null, 2));
        console.log("should be");
        console.log(JSON.stringify(myJQuery[0], null, 2));
    }
)

// Render
myJQuery.survey({ model: mySurvey })

Specify your

andrewtelnov commented 3 years ago

@aaronsheldon Here is the working example. I do not see any issues here.

Thank you, Andrew

aaronsheldon commented 3 years ago

It works fine with all the After Renders except onAfterRenderSurvey. I have not seen the problem with onAfterRenderPage

andrewtelnov commented 3 years ago

@aaronsheldon survey.onAfterRenderSurvey. The html element for survey is a div element where you ask survey to render.

Thank you, Andrew