• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

JQTouch and AJAX

Hi

I am quite new to jqtouch but I am trying to integrate it with an existing website.

I have set up a single html page, however I want the links to go grab content from different pages on the existing website. I decided the easiest way to do this would be using AJAX. I set up a <div> on the single page for each of the other pages i.e.

<div id="home"></div>
<div id="about"></div>
<div id="content"></div>

I then have the following  which loads the content from the pages in to the single page divs:
(document).ready(function(){
        $('#home').load('http://www.mysite.co.uk/home.html' + ' #content');
        $('#about').load('http://www.mysite.co.uk/about.html' + ' #content' );
        $('#content').load('http://www.mysite.co.uk/content.html + ' #content' );
             });

The reason I have to do this is that my single html file is sat in a different directory to all other pages.

The above seems to work fine for what I want however my question is once the content is loaded I need to do something with any links that appear in the content as they do not work. Is there a way in ajax to change the reference of the links in the content and point them to the correct place as above?

0
Brandon2k1
Asked:
Brandon2k1
  • 2
  • 2
1 Solution
 
JF0Commented:
After you load the page can you call some jquery functions to find your links and change the attributes (link locations)

http://api.jquery.com/attr/
0
 
Brandon2k1Author Commented:
Im pretty sure thats the correct way forward, Im just stuggling to actually make it happen!! I will keep reading to see if i  can grasp it, but if you had an example of how you see it working that would be great.

Any other comments welcome!
0
 
JF0Commented:
$('a').each(function() {
      $(this).attr("href", function(index, old) {
            return old.replace("find", "replace");
      });
});
0
 
Brandon2k1Author Commented:
Sorry for the delay in getting back to you. You hit the nail on the head. Used a slightly different function to get the result but changing the attr had the desired effect.

Thanks.

Chris.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now