Skip to content

Instantly share code, notes, and snippets.

@dpawluk
Last active November 15, 2017 18:41
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 dpawluk/47e4cfdcbccf23988ca348fc803b5eb1 to your computer and use it in GitHub Desktop.
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
<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