0

I have React application with Tabs that call up separate JS files. I'm using SurveyJS in which every survey has a complete button. On my Parent page, my Save button i need to have it call every JS file , .onComplete method

Example of Parent page with Tabs

import {Tab, Tabs } from 'react-bootstrap';
import * as Survey from "survey-react";
import "survey-react/survey.css";
import SectionA from './SectionA';
import SectionB from './SectionB';

//Tabs
<Tabs activeKey={this.state.activeTab} onSelect={this.handleSelect}>
     <Tab eventKey={1} title="CORE SEC A."><SectionA offline={this.state.online} /></Tab>
     <Tab eventKey={2} title="CORE SEC B."><SectionB /></Tab>
     ...
</Tabs>


//Save button function
const sendSurveyDataAPI = () => { 
   // need to call all the .onComplete on child pages such as SectionA, SectionB   (.js files)
}

Child page Example

var survey = new Survey.Model(json);

// need to call up this from Parent 
 survey
.onComplete
.add(function (result) {

        // don't want this in children  
        handleSave(result.data);

})
  • I think this answer might help you: https://stackoverflow.com/questions/37949981/call-child-method-from-parent – JakeD Oct 29 '19 at 00:20
  • I did that actually. The "class" components. with ` this.child = React.createRef();` and all my child pages would behave strange with radio and check boxes not letting me check them , or rather i could check them but it didn't visibly show unless i left the page and came back to it. very odd –  Oct 29 '19 at 17:06

0 Answers0