Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…sing onAfterRenderQuestion to update DOM
  • Loading branch information
tsv2013 committed Jan 16, 2018
1 parent f14ecc4 commit 7533793
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
22 changes: 18 additions & 4 deletions src/react/reactpage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ export class SurveyPage extends React.Component<any, any> {
componentDidMount() {
this.doAfterRender();
}
componentWillUnmount() {
var el: any = this.refs["root"];
if (!!el) {
el.removeAttribute("data-rendered");
}
}
componentDidUpdate(prevProps, prevState) {
this.doAfterRender();
}
private doAfterRender() {
var el = this.refs["root"];
if (el && this.survey) this.survey.afterRenderPage(el);
var el: any = this.refs["root"];
if (el && this.survey && el.getAttribute("data-rendered") !== "r") {
el.setAttribute("data-rendered", "r");
this.survey.afterRenderPage(el);
}
}
render(): JSX.Element {
if (this.page == null || this.survey == null || this.creator == null)
Expand Down Expand Up @@ -120,8 +129,9 @@ export class SurveyPanel extends React.Component<any, any> {
this.doAfterRender();
}
private doAfterRender() {
let el = this.refs["root"];
if (el && this.survey) {
let el: any = this.refs["root"];
if (el && this.survey && el.getAttribute("data-rendered") !== "r") {
el.setAttribute("data-rendered", "r");
this.survey.afterRenderPanel(this.panel, el);
}
}
Expand All @@ -131,6 +141,10 @@ export class SurveyPanel extends React.Component<any, any> {
["isVisible", "renderWidth", "innerIndent", "rightIndent", "state"],
"react"
);
var el: any = this.refs["root"];
if (!!el) {
el.removeAttribute("data-rendered");
}
}
}
render(): JSX.Element {
Expand Down
14 changes: 12 additions & 2 deletions src/react/reactquestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,26 @@ export class SurveyQuestion extends React.Component<any, any> {
["visibleIndex", "renderWidth", "indent", "rightIndent, isReadOnly"],
"react"
);
var el: any = this.refs["root"];
if (!!el) {
el.removeAttribute("data-rendered");
}
}
}
componentDidUpdate(prevProps, prevState) {
this.doAfterRender();
}
private doAfterRender() {
if (this.questionBase) {
var el = this.refs["root"];
if (el && this.questionBase.survey)
var el: any = this.refs["root"];
if (
el &&
this.questionBase.survey &&
el.getAttribute("data-rendered") !== "r"
) {
el.setAttribute("data-rendered", "r");
this.questionBase.survey.afterRenderQuestion(this.questionBase, el);
}
}
}
render(): JSX.Element {
Expand Down
14 changes: 12 additions & 2 deletions src/react/reactquestionmatrixdropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,24 @@ export class SurveyQuestionMatrixDropdownCell extends ReactSurveyElement {
["visible", "isReadOnly"],
"react"
);
var el: any = this.refs["cell"];
if (!!el) {
el.removeAttribute("data-rendered");
}
}
}
componentDidUpdate(prevProps, prevState) {
this.doAfterRender();
}
private doAfterRender() {
var el = this.refs["cell"];
if (el && this.cell && this.cell.question.survey) {
var el: any = this.refs["cell"];
if (
el &&
this.cell &&
this.cell.question.survey &&
el.getAttribute("data-rendered") !== "r"
) {
el.setAttribute("data-rendered", "r");
var options = {
cell: this.cell,
cellQuestion: this.cell.question,
Expand Down

0 comments on commit 7533793

Please sign in to comment.