// javascript for ajax pagination//
document.observe("dom:loaded", function() {
// the element in which we will observe all clicks and capture
// ones originating from pagination links
var container = $(document.body)
if (container) {
var img = new Image
img.src = '/images/spinner.gif'
function createSpinner() {
return new Element('img', { src: img.src, 'class': 'spinner' })
}
container.observe('click', function(e) {
var el = e.element()
if (el.match('.pagination a')) {
el.up('.pagination').insert(createSpinner())
new Ajax.Request(el.href, { method: 'get' })
e.stop()
}
})
}
})
Why is this script inserting two spinner images?
here is the html
<div style="margin-top:25px;">
<div class="pagination ajax">
<span class="disabled prev_page">« Previous</span>
<span class="current">1</span>
<a href="/posts?page=2" rel="next">2</a>
<a href="/posts?page=3">3</a>
<a href="/posts?page=2" class="next_page" rel="next">Next »</a>
</div>
<br style="clear:both;"/>
</div>