[jQuery] Re: Translate standard HREF's into JavaScript expressions -- string manipulation help..

2008-10-14 Thread jsw_nz


Hi Michael  Paul

Thanks for your replies - both expressions work !
(plus another I worked on prior to your responses).
Just have to say thanks for the great jquery community support
offerred here

While I have your attention - had another question to ask

Since I am translating the standard hrefs with calls to jquery ajax
fpr tje entire CMS
how does this effect SEO and other bots that 'spider' through the site

Will the bots and search engines SEE the original HREF'S
and not execute the ajax calls - if so would Paul's approach be better
since it amounts to an onClick handler -where the status bar shows
original HREF

Thanks guys
very much appreciated!




[jQuery] Re: Translate standard HREF's into JavaScript expressions -- string manipulation help..

2008-10-14 Thread Michael Geary

I like Paul's solution better than mine. It's cleaner to attach an event
handler rather than rewrite the href attribute.

Does your page have a large number of a tags, or just a few? If there are
a lot of them and the jQuery code slows the page load down, you could use
event delegation to fix that, otherwise Paul's code is fine.

Neither bit of code has the slighest effect on search engines. Their spiders
don't run your JavaScript code - they see the original hrefs as they appear
in the HTML code your server generates. If you do a View Source in the
browser, that's what the spiders see.

-Mike

 Hi Michael  Paul
 
 Thanks for your replies - both expressions work !
 (plus another I worked on prior to your responses).
 Just have to say thanks for the great jquery community 
 support offerred here
 
 While I have your attention - had another question to ask
 
 Since I am translating the standard hrefs with calls to 
 jquery ajax fpr tje entire CMS how does this effect SEO and 
 other bots that 'spider' through the site
 
 Will the bots and search engines SEE the original HREF'S
 and not execute the ajax calls - if so would Paul's approach 
 be better since it amounts to an onClick handler -where the 
 status bar shows original HREF
 
 Thanks guys
 very much appreciated!
 
 



[jQuery] Re: Translate standard HREF's into JavaScript expressions -- string manipulation help..

2008-10-14 Thread jsw_nz

Hi Michael,

Thanks for the pointers - no -- the treatment of rel attribute on a
tags
is limited -  so I guess it will be OK - i run the code on Ajax
success event -
- again thanks much !


[jQuery] Re: Translate standard HREF's into JavaScript expressions -- string manipulation help..

2008-10-13 Thread Paul Mills

Hi,
Rather than replace the href in the source code you could add a click
handler to call your JavaScript function.
A bit like this:

$(function(){
  $('a[rel=paginate]').click(function(){
ajax_getPage($(this).attr(href).split(=)[1]);
return false;
  });
});

Paul

On Oct 12, 10:56 pm, jsw_nz [EMAIL PROTECTED] wrote:
 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-2content/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.


[jQuery] Re: Translate standard HREF's into JavaScript expressions -- string manipulation help..

2008-10-12 Thread Michael Geary

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-2content/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.