Question T3340
Visible to All Users

What is the function  event for adding page on surveyjs

created 5 years ago (modified 5 years ago)

[Ticket cloned from T3320: How to customize a widget]

Hello!!

What is the function  event for adding page on surveyjs?

On 1/27/2020 12:27 PM, Support Support wrote:

Answers approved by surveyjs Support

created 5 years ago

Hello,

You should use the https://surveyjs.io/Documentation/Survey-Creator/?id=surveycreator#onPageAdded event as shown in this live sample - https://plnkr.co/edit/tjcXxlbtJpdvO2uI3d3M?p=preview

Thanks, Serge
SurveyJS Team

    Show previous comments (1)

      Hello,

      Could you please describe your business case in greater details? It's hard to suggest something without any context.

      Thanks, Serge
      SurveyJS Team

        I am trying to get the json object if the user click on add new page. How do I get the previous page with the json object

        On 2/5/2020 10:54 AM, Support Support wrote:

          Hello,
          I am afraid that you need the previous json for something bigger and this is just a step that you believe need to implement something. However, this step maybe not needed at all. What is the final goal?

          Thank you,
          Andrew
          SurveyJS Team

          created 5 years ago

          Hello,
          survey.onPageAdded event.

          Thank you,
          Andrew
          SurveyJS Team

            Show previous comments (8)

              still not working

              On 2/6/2020 2:48 PM, Support Support wrote:

              JavaScript

              this.surveyCreator.onPageAdded.add(function(sender, options) {
              alert(JSON.stringify(this.surveyCreator.survey.pages[0].toJSON()));
              });

              Code

                this is error an occur, Cannot read property 'survey' of undefined

                On 2/6/2020 2:48 PM, Support Support wrote:

                JavaScript

                this.surveyCreator.onPageAdded.add(function(sender, options) {
                alert(JSON.stringify(this.surveyCreator.survey.pages[0].toJSON()));
                });

                Code

                  Hello,

                  You've got the wrong this context. You can use the fat arrow notation here:

                  JavaScript
                  this.surveyCreator.onPageAdded.add((sender, options) => { alert(JSON.stringify(this.surveyCreator.survey.pages[0].toJSON())); });

                  If you are a licensed user of SurveyJS Creator please write us from the e-mail linked to your license so we can recognize you as a licensed customer. Thank you for your understanding.

                  Thanks, Serge
                  SurveyJS Team