Skip to content

Instantly share code, notes, and snippets.

@martinyung
Last active June 25, 2017 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinyung/99c3159599e4264285300aeff59bd0c1 to your computer and use it in GitHub Desktop.
Save martinyung/99c3159599e4264285300aeff59bd0c1 to your computer and use it in GitHub Desktop.
conversational-form with react.js - add cf info
class Hello extends Component {
...
componentDidMount(){
// customize your questions here
this.refs.name.setAttribute('cf-questions', "What is your name?");
this.refs.email.setAttribute('cf-questions', "What is your email?");
this.refs.description.setAttribute('cf-questions', "Describe your requirement");
this.cf = window.cf.ConversationalForm.startTheConversation({
formEl: this.refs.form,
context: document.getElementById("cf-context"), // <-- bind this to an element instead of html body
flowStepCallback: (dto, success, error) => {
success();
},
submitCallback: () => {
// action when form submitted
console.log("Form submitted...");
}
});
}
render() {
...
}
}
export default Hello;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment