Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create WebMerge Documents From Knack via AJAX
$(document).on('knack-scene-render.scene_3', function(event, scene) {
$('#view_4 .view-header').after('<div style="padding:15px"><a href="#" id="webmerge" class="kn-button">Send to WebMerge</a></div>');
// link hander: send to webmerge
$('#webmerge').click(function(event) {
event.preventDefault();
// get data
var data = Knack.models['view_4'].toJSON();
log('data!');log(data);
Knack.showSpinner();
$.ajax({
url: 'https://www.webmerge.me/merge/20103/37f4te',
data: {
Email: data.field_3_raw.email,
Phone: data.field_2_raw,
Company: data.field_1_raw,
Description: data.field_5_raw,
Amount: data.field_6_raw
},
type: 'POST',
success: function() {
alert('Contract Created!');
Knack.hideSpinner();
},
error: function() {
alert('There was an error creating the contract');
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment