Trouble with .fadeIn() and removeClass()/addClass()

Hey dudes and dudettes!

First, here’s the code I’m trying to get through:

function addSponsors(s) {
	var sn = prompt("New sponsors name?");
	if(sn !=null) {'../wp-content/plugins/NewLife-EventCalendar/php/addSponsor.php',{sponsorName: sn}, function(r) {
			if(r) {
				<tr id="row' + r + '">\\
					<td class="id">' + r + '</td>\\
					<td class="name">' + sn + '</td>\\
					<td><a onClick="editSponsor('+r+')">Edit</a></td>\\
					<td><a onClick="deleteSponsor('+r+')">Delete</a></td>\\
				jQuery('#row'+r).fadeIn(function() {
					jQuery('#sponsorList tr').each(function(i) {
						jQuery('#sponsorList tr').removeClass('odd');
						if(++i %2 == 0) {
							jQuery('#sponsorList tr').addClass('odd');

It’s a function for an event calendar, for the user to be able to add a “sponsor” for the event. They type the name into the prompt, and it takes the value, posts it to the given PHP script and then returns the value of the inserted id. updates the table that holds all the sponsor information.

The 2 problems I’m running into, are these:

  1. The new table row dosen’t fade in. It just shows up.
  2. I have every other row in the table highlighted. I can’t figure out what needs to be done to check to see if the newly added table row is an “odd” or “even” row. If it’s odd, then it add’s the ‘odd’ class to the row to make it highlighted.

Any suggestions?


tried it out, still not working right.

This is why I like server side… eh!

As far as I know, fadeIn method has first parameter ‘duration’ and second parameter is for the callback function. So it is all because you have used callback as first parameter. So try once:

jQuery('#row'+r).fadeIn('slow', function() {