Question T4562
Visible to All Users

I would like to create a json as question and append the json to the new page

created 5 years ago (modified 5 years ago)

[Ticket cloned from T4192: How do I call the function of remove question button on the surveyj, what is the function call?]

I would like to create a json as question and append the json to the new page

Example :  let json = {"type" : "test","name" : "question1"};

var u = this.surveyCreator.survey.addNewPage("pages1");
              u.addNewQuestion(json);
my problem, I am facing, it's not appending to the new page
On 6/15/2020 12:23 PM, Serge T [surveyjs Support] wrote:

Answers approved by surveyjs Support

created 5 years ago

Hello,

This can be achieved via the following code:

JavaScript
function addNewPage() { var page = creator.addPage(); let json = {"type" : "text", "name" : "question2", "title": "My Question"}; var question = page.addNewQuestion(json.type, json.name); question.fromJSON(json); creator.selectedElement = page; }

Here is the working sample - https://plnkr.co/edit/WBmwQYTPHo8g4Mua

Thanks, Serge
SurveyJS Team

    Comments (2)

      I would like to trigger an event after click  the delete button for the question as well as for the page

      On 6/30/2020 12:16 PM, Serge T [surveyjs Support] wrote:

        Hello,

        I've created a separate ticket on your behalf (T4563: I would like to trigger an event after click  the delete button). It has been placed in our processing queue and will be answered shortly.

        Thanks, Serge
        SurveyJS Team