Question T2025
Visible to All Users

force render page

created 6 years ago

Hello,

How can I force the first page to be rerender after adding buttons with preprend in survey editor?

Thanks in advance.

Comments (1)

    Hello,

    Sorry, but I'm not sure I've understood you. Could you please describe in more details - what buttons and how do you add them?
    It would be better if you could illustrate your question with a plunker sample.

    Thanks, Serge
    SurveyJS Team

    Answers approved by surveyjs Support

    created 6 years ago

    I've fixed "page adding" after page renamed. Fix will be available in the nearest update.

    Thanks, Serge
    SurveyJS Team

      created 6 years ago

      Hello,

      You need to use the following code:

      JavaScript
      var subscriber = function(sender, options) { options.survey.onAfterRenderPage.add(function (editor, options) { console.log('after render page'); var pageId = options.page.id; console.log(pageId); $('#' + pageId).prepend( '<div><button class="btn" id=custom' + pageId + '>Custom button</button></div>'); }); }; editor.onTestSurveyCreated.add(subscriber); editor.onDesignerSurveyCreated.add(subscriber);

      Here is the working sample - https://next.plnkr.co/edit/XqIgz9LuoK3AO5z0?preview

      Thanks, Serge
      SurveyJS Team

        Show previous comments (3)

          Thank you Serge.

          I have updated to 1.0.87 version and now custom buttons don't appear until you add a question, does it exist a way to keep them in the creator from the beggining ?

          version 1.0.75 (working fine)

          https://next.plnkr.co/edit/4XQe1QSHVV0Aa3V7

          version 1.0.87 (custom buttons disappeared)

          https://next.plnkr.co/edit/YUo2O4QfCFO3YkTx?preview

          Thank you in advance.

            Hello,

            Your custom button is hidden by the empty page banner ("Please drop a question hereā€¦") because the page is actually empty - there is no questions on the page.
            This banner has a bug in previous versions - it didn't cover all the page area.

            Your custom button become visible after you added at least one question. You can create a custom widget that will implement your button functionality. Is it suitable for you?

            Thanks, Serge
            SurveyJS Team

              Yes, a custom widget may be a solution.

              Thank you for your help.

              Other Answers

              created 6 years ago

              I am using onAfterRenderPage and prepend method (jquery) to add custom buttons on page but when I load data with editor.text the first page doesn't render and doesn't show the custom buttons.

              https://next.plnkr.co/edit/XatzZSOdffUnWqQj

              Thank you very much for your help.