Eddie Shipman
asked on
jQuery form cloning extras
Got the code here: http://jsfiddle.net/vdUuy/11/
How would I add the following span to the participants div and add the click handler so it would remove the participant added?
Also, it looks like the click handler isn't working, don't know why.
How would I add the following span to the participants div and add the click handler so it would remove the participant added?
<span class="remove_participant"> </span>
Also, it looks like the click handler isn't working, don't know why.
just to clarify - the listParticipants function should now look like:
function listParticipants(){
list.empty();
for(var i = 0, l = participants.length; i < l; i++){
var o = participants[i];
var p = $('<p>');
p.text(o.fname + ' ' + o.lname);
var s = $('<span>');
s.addClass('remove_participant');
s.data('index', i);
s.click(deleteParticipant);
p.append(s);
list.append(p);
}
}
ASKER
The fiddle has the add-participant id on the button now but I can't understand why the remove-participant doesn't have the image. I see the styling in FB but not see the image.
i don't think you linked the right fiddle, then - that one definitely does not have a button with id of add-participant... and the button doesn't work... can you double check the link?
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Saved my butt, again, thanks.
glad i could help. i'm out for the day, but i'll check in again tomorrow if anything else comes up for this.
p.text(o.fname + ' ' + o.lname);
p.data('index', i);
p.click(deleteParticipant)
list.append(p);
to this
var s = $('<span>');
s.addClass('remove_partici
s.data('index', i);
s.click(deleteParticipant)
p.append(s);
list.append(p);
I tried updating the fiddle, but there are some other issues (e.g., there's no element with id of "add-participant")
you also want to use e.preventDefault() in any click action triggered by a link to stop the default behavior
someLink.click(function(e)
// do stuff..
e.preventDefault();
});