react-hubspot-form
Advanced tools
Comparing version 1.3.6 to 1.3.7
@@ -43,3 +43,2 @@ 'use strict'; | ||
_this.findFormElement = _this.findFormElement.bind(_this); | ||
_this.onSubmit = _this.onSubmit.bind(_this); | ||
return _this; | ||
@@ -51,2 +50,4 @@ } | ||
value: function createForm() { | ||
var _this2 = this; | ||
if (window.hbspt) { | ||
@@ -62,3 +63,8 @@ // protect against component unmounting before window.hbspt is available | ||
var options = _extends({}, props, { | ||
target: '#' + this.el.getAttribute('id') | ||
target: '#' + this.el.getAttribute('id'), | ||
onFormSubmit: function onFormSubmit($form) { | ||
// ref: https://developers.hubspot.com/docs/methods/forms/advanced_form_options | ||
var formData = $form.serializeArray(); | ||
_this2.props.onSubmit(formData); | ||
} | ||
}); | ||
@@ -74,3 +80,3 @@ window.hbspt.forms.create(options); | ||
value: function loadScript() { | ||
var _this2 = this; | ||
var _this3 = this; | ||
@@ -80,4 +86,4 @@ var script = document.createElement('script'); | ||
script.onload = function () { | ||
_this2.createForm(); | ||
_this2.findFormElement(); | ||
_this3.createForm(); | ||
_this3.findFormElement(); | ||
}; | ||
@@ -97,3 +103,2 @@ script.src = '//js.hsforms.net/forms/v2.js'; | ||
this.setState({ loaded: true }); | ||
form.addEventListener('submit', this.onSubmit); | ||
if (this.props.onReady) { | ||
@@ -107,17 +112,2 @@ this.props.onReady(form); | ||
}, { | ||
key: 'onSubmit', | ||
value: function onSubmit() { | ||
var _this3 = this; | ||
clearInterval(this.onSubmitInterval); | ||
this.onSubmitInterval = setInterval(function () { | ||
if (!_this3.el.querySelector('iframe')) { | ||
clearInterval(_this3.onSubmitInterval); | ||
if (_this3.props.onSubmit) { | ||
_this3.props.onSubmit(); | ||
} | ||
} | ||
}, 1); | ||
} | ||
}, { | ||
key: 'componentDidMount', | ||
@@ -134,5 +124,3 @@ value: function componentDidMount() { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
clearInterval(this.onSubmitInterval); | ||
} | ||
value: function componentWillUnmount() {} | ||
}, { | ||
@@ -139,0 +127,0 @@ key: 'render', |
{ | ||
"name": "react-hubspot-form", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "react", |
Sorry, the diff of this file is not supported yet
253218
11
122