Created
January 3, 2018 14:25
-
-
Save anilmeena/b28cc65857563a8a882833b53e70720d to your computer and use it in GitHub Desktop.
Auto display grid view on desktop & list view on mobile in shopify collection template
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
<!-- [Auto display grid view on desktop & list view on mobile in shopify collection template ] --> | |
<script> | |
function responsiveFn() { | |
width = jQuery( window ).width(); | |
height = jQuery( window ).height(); | |
// Do a custom code here | |
if(width < 768){ | |
jQuery('button[data-view = "list"]').click(); | |
}else{ | |
jQuery('button[data-view = "grid"]').click(); | |
} | |
} | |
// load() event and resize() event are combined | |
jQuery(window).ready(responsiveFn).resize(responsiveFn); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment