- Move your script from wherever it is into theme.liquid
- Wrap it in a function
- Call the function
- Call the function again whenever ajax has loaded something.
- See example below. I've used the agree to terms of service snippet.
Last active
August 29, 2015 14:14
-
-
Save kyledurand/89a29a129f075326ffa4 to your computer and use it in GitHub Desktop.
Getting scripts to work on ajaxified cart drawers etc...
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
<script> | |
var agree = function(){ | |
$('[name="checkout"], input[name="goto_pp"], input[name="goto_gc"]').click(function() { | |
if($('#agree').is(':checked')){ | |
$(this).submit(); | |
} | |
else{ | |
alert("You must agree with the terms and conditions of sales to check out."); | |
return false; | |
} | |
}); | |
} | |
$( document ).ajaxComplete(function() { | |
agree(); | |
}); | |
agree(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment