JQTouch and AJAX

Posted on 2011-05-10
Medium Priority
Last Modified: 2012-05-11

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:
        $('#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?

Question by:Brandon2k1
  • 2
  • 2
LVL 16

Accepted Solution

JF0 earned 2000 total points
ID: 35730285
After you load the page can you call some jquery functions to find your links and change the attributes (link locations)


Author Comment

ID: 35730436
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!
LVL 16

Expert Comment

ID: 35730537
$('a').each(function() {
      $(this).attr("href", function(index, old) {
            return old.replace("find", "replace");

Author Closing Comment

ID: 35752775
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.



Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question