I think it would go something like this (thoroughly untested):

    $(function() {
        $('a[rel="paginate"]').each( function() {
            this.href = this.href.replace(
                /^.*aid=(.+)$/,
                "javascript:ajax_getPage('$1')"
            );
        });
    });

-Mike

> From: jsw_nz
> 
> Just needing some pointers on jQuery string manipulation
> 
> I have a content management system
> - in which I am applying experimental (jQuery) ajax functions 
> - these work OK - !
> 
> But ather than hack the CMS source code, I want to create a 
> function that replaces the standard hrefs that the CMS generates
> >> with javascript functions, which are triggered on Ajax 
> success event
> 
> 
> 
> basically here are the translation requirements:
> 
> TRANSLATE
> FROM
> <a rel="paginate" href="index.php?aid=1-2">content</a>
> 
> TO
> <a href="javascript:ajax_getPage('1-2')">content</a>
> 
> guessing it is a matter of getting the hrefs, based on rel="paginate"
> as a selector;
> then replacing with the javascript string, where the key 
> variable is aid, ie "1-2" in this case...
> 
> I have tried getting this to work, but am having problems so 
> wanted to ask if any more experience jQuery programmers might 
> provide pointers
> 
> thanks is advance.
> 

Reply via email to