Try:
container.observe('click', function(e) {
* var el = e.element().tagName == 'a' ? e.element() :
e.element().up('a');*
if (el.match('.pagination a')) {
el.up('.pagination').insert(createSpinner())
new Ajax.Request(el.href, { method: 'get' })
e.stop()
}
})
On Fri, Sep 25, 2009 at 12:32 PM, Marcelo Barbudas <[email protected]> wrote:
>
> Hi.
>
> I am using a Rails plugin called will_paginate. For AJAX pagination they
> use the solution presented here:
> http://wiki.github.com/mislav/will_paginate/ajax-pagination
> The code is something like:
>
> |document.observe("dom:loaded", function() {
> [..]
> 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()
> [..]
> })
> |
>
> The only problem is that this doesn't work if there are images in the
> links.
> <a class="next_page" rel="next" href="/link">
> <img src="/images/right-point.gif?1244992605" alt="Right-point"/></a>
> When clicking on the image the trigger is called for the img tag, not
> the link.
>
> Here is the fix I've implemented:
> container.observe('click', function(e) {
> if (e.element().match('img'))
> var el = e.element().ancestors()[0]
> else
> var el = e.element()
>
> if (el.match('.pagination a')) {
> el.up('.pagination').insert(createSpinner())
> new Ajax.Request(el.href, { method: 'get' })
> e.stop()
> }
> })
>
> I am not the best JS programmer, so maybe someone has a better solution.
>
> --
> Cheers,
> M.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---