question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`onAfterRenderPage` fires only once

See original GitHub issue

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

It sounds like a bug, the docs says

The event is fired right after a page is rendred in DOM. Use it to modify html elements. There are two parameters in options: options.currentPage, options.htmlElement

it sounds like we can use to modify each page after it’s rendered. It also provides a currentPage

What is the current behavior?

onAfterRenderPage is firing only once on page0

What is the expected behavior?

onAfterRenderPage should fire on every page render

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

create a survey with multiple pages, add an onAfterRenderPage handler and try it.

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

Tested page URL: https://plnkr.co/edit/5a1w1O5tJhdfKIwslYCo

Test code

Survey.Survey.cssType = "bootstrap";
Survey.defaultBootstrapCss.navigationButton = "btn btn-green";

window.survey = new Survey.Model({
 "pages": [
  {
   "name": "page1",
   "questions": [
    { "type": "text", "name": "satisfaction", "title": "How satisfied are you with the Product?" }
   ]
  },
  {
   "name": "page2",
   "questions": [
    { "type": "text", "name": "why", "title": "why?" }
   ]
  }
 ]
});
survey.onComplete.add(function(result) {
    document.querySelector('#surveyResult').innerHTML = "result: " + JSON.stringify(result.data);
});

survey.onAfterRenderPage .add(function(result, options) {
  alert(options.page.name);
});

survey.data = {satisfaction: 'ok, i guess', why: 'because'};

$("#surveyElement").Survey({ 
    model: survey 
});

Specify your

  • browser: Chrome
  • browser version: 61.0.3163.91
  • surveyjs platform (angular or react or jquery or knockout or vue): jquery
  • surveyjs version: 0.12.23

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
akhourycommented, Sep 19, 2017

ok so onCurrentPageChanged works on every page change, however it doesn’t fire for the initial page.

workaround

use both, onAfterRenderPage which fires for page0, and onCurrentPageChanged which fires for every page after that.

0reactions
the-glimacommented, Jun 15, 2021

Still onAfterRenderPage doesn’t fired when first page is rendered, I didn’t find any other event to use when Survey is loaded also.

Tried a bunch of events onStarted, onAfterRenderPage, onAfterRenderPanel, etc… nothing is being fired at first load.

Read more comments on GitHub >

github_iconTop Results From Across the Web

event on page change - surveyjs Support
What fires first? onCurrentPageChanged or onAfterRenderPage ? Is there an event for when the survey state changes from "running" to "completed" ...
Read more >
javascript - on change event fires only once - Stack Overflow
i'm trying to update cart whenever product quantity is changed. but jquery code is stop working after first time updating cart items. here...
Read more >
SurveyModel | SurveyJS
onAfterRenderPage event. The event is fired right after a page is rendered in DOM. Use it to modify HTML elements. sender - the...
Read more >
survey-knockout - UNPKG
2868, * Please note, it runs only one changing the expression result. ... 3524, * The event is fired before the survey is...
Read more >
Why does my click event only fire once? - Codecademy Forums
What is driving me crazy is that it only fires ONCE - why can I not click it again to generate another random...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found