Last active
November 15, 2017 18:41
-
-
Save dpawluk/47e4cfdcbccf23988ca348fc803b5eb1 to your computer and use it in GitHub Desktop.
Shows how ticket.save hook should be used in a v2 app. Very minimal example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h2>Test Save Hooks</h2> | |
<!-- https://github.com/zendesk/zendesk_app_framework_sdk --> | |
<button id="failMeNow">Force Fail</button> | |
<script type="text/javascript" src="https://assets.zendesk.com/apps/sdk/2.0/zaf_sdk.js"></script> | |
<script | |
src="https://code.jquery.com/jquery-3.2.1.min.js" | |
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" | |
crossorigin="anonymous"> | |
</script> | |
<script> | |
// Initialise the Zendesk JavaScript API client | |
// https://developer.zendesk.com/apps/docs/apps-v2 | |
var client = ZAFClient.init(); | |
client.invoke('resize', { width: '100%', height: '400px' }); | |
client.on('app.registered', init); | |
client.on('ticket.save', saveHook); | |
function init(){ | |
console.log("Started"); | |
}; | |
function saveHook(){ | |
return new Promise((done, fail) => { | |
$('#failMeNow').click(function(event){ | |
fail(); | |
}); | |
setTimeout(function(){ | |
done(); | |
}, 5000); | |
}); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment