Skip to content

Instantly share code, notes, and snippets.

@rubenRP
Created November 2, 2015 11:24
Show Gist options
  • Save rubenRP/fe1ff2a3cabdfeef3a9d to your computer and use it in GitHub Desktop.
Save rubenRP/fe1ff2a3cabdfeef3a9d to your computer and use it in GitHub Desktop.
Script de scroll infinito en Category/list
<script type="text/javascript">
//<![CDATA[
function sendLoadMoreProductsRequest() {
if ($$('.next').first()) {
var url = $$('.next').first().readAttribute('href');
$$('.product-loading a').first().hide();
$$('body').first().innerHTML += '<div id="ajax-loading"><div class="uil-ripple-css" style="-webkit-transform:scale(0.75)"><div></div><div></div></div></div>';
new Ajax.Request (url, {
method: 'get',
onSuccess: function (response) {
var div = document.createElement('div');
div.innerHTML = response.responseText;
$$('.pages').first().innerHTML = $(div).select('.pages').first().innerHTML;
$$('.product-list').first().innerHTML += $(div).select('.product-list').first().innerHTML;
$('ajax-loading').remove();
if ($(div).select('.product-loading').length > 0) {
$$('.product-loading a').first().innerHTML = $(div).select('.product-loading a').first().innerHTML;
$$('.product-loading a').first().show();
} else {
$$('.product-loading').first().remove();
}
}
});
}
}
// Event.observe(window, "load", function () {
// window.scrollTo(0, 0);
// });
//]]>
</script>
function sendLoadMoreProductsRequest() {
if ($$('.next').first()) {
var url = $$('.next').first().readAttribute('href');
$$('.product-loading a').first().hide();
$$('body').first().innerHTML += '<div id="ajax-loading"><div class="uil-ripple-css" style="-webkit-transform:scale(0.75)"><div></div><div></div></div></div>';
new Ajax.Request (url, {
method: 'get',
onSuccess: function (response) {
var div = document.createElement('div');
div.innerHTML = response.responseText;
$$('.pages').first().innerHTML = $(div).select('.pages').first().innerHTML;
$$('.product-list').first().innerHTML += $(div).select('.product-list').first().innerHTML;
$('ajax-loading').remove();
if ($(div).select('.product-loading').length > 0) {
$$('.product-loading a').first().innerHTML = $(div).select('.product-loading a').first().innerHTML;
$$('.product-loading a').first().show();
} else {
$$('.product-loading').first().remove();
}
}
});
}
}
// Event.observe(window, "load", function () {
// window.scrollTo(0, 0);
// });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment