Tag Archives: jQuery

Today I had an issue with html duplication when using jQuery mobile and ajax.

What was the issue?

The problem was that when a user submits a particular page, on the new page that loads, the previous page’s html was still visible in the code of the page. Although it wasn’t visible on the new page, it was causing some problems with automatic tests which was finding different controls with the same IDs.

Resolution:

The problem was that the source page didn’t have this attribute in the page element: Continue reading

These past days, I was having a problem with links for an iPad web app. The problem was that when I submit a form (step 1) and go to the next form (step 2), the link to return back to step 1 was not working. Apparently the problem is caused by Ajax. The solution is the following, instead of using the normal form tag to init a form:

In jQuery you have multiple selectors to either select single objects or a whole bunch. I needed to select an image by its alt tag, and guess what, there is also a selector for alt tags. You need to do the following:

$(‘img[alt=”My Alt Image”]’)

I needed this so that I could change the class and set the selected image as active, by searching the alt tag as below:

$(‘img[alt=”My Alt Image”]’).addClass(‘.active’);

Something else that might be useful is to revert the active image, to a normal image. Instead of using the alt tag this time you can use the ‘active’ class selector as below:

Update 2011: For those people who had problems with the below instructions.. please find in on my website here. And when you’re there take a look at my site and see what you think about it 🙂

Lightbox 2 has the functionality to set maximum width and height. But what about previous versions? To set the maximum image width and height for lightbox (version 0.5) you need to do some extra coding yourself. Open the jquery.lightbox-0.5.js file and search for the next pieces of code (in bold below):

settings = jQuery.extend({
maxWidth: null,
maxHeight: null,
...

Then search for the next function (in bold) and write copy and paste the code underneath it: Continue reading