Skip to content

Instantly share code, notes, and snippets.

@cdeutsch
Last active December 23, 2015 23:08
Show Gist options
  • Save cdeutsch/6707524 to your computer and use it in GitHub Desktop.
Save cdeutsch/6707524 to your computer and use it in GitHub Desktop.
Wire up Scan button in Xamarin.Web.BarcodeSample app
<script type="text/javascript" src="~/scripts/mt.js"></script>
<script type="text/javascript">
$(document).ready(function () {
// listen for scan finished event triggered from native code.
Mt.App.addEventListener('scanComplete', function (data) {
if (data && data.code) {
if (confirm('Use the code ' + data.code + '?')) {
$('#PromoCode').val(data.code);
}
}
});
$('#scanBarcode').on('click', function (e) {
e.preventDefault();
// fire event in native code.
Mt.App.fireEvent('scanBarcode', {});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment