Created
November 2, 2015 11:24
-
-
Save rubenRP/fe1ff2a3cabdfeef3a9d to your computer and use it in GitHub Desktop.
Script de scroll infinito en Category/list
This file contains 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 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> |
This file contains 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
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