Reputation: 1911
I have a list page with multiple users listed (a favorites list for the logged in users). There is a message button which opens up an overlay. The user can then send a message across using the message box in the overlay. The jQuery code is:
$('#message').click(function(){
var str = $(this).attr('name');
var n=str.split("####");
$('#user_new').val(n[0]);
$('#msgto_username').html(n[1]);
$('#bodybg').show();
$('.confirmBox').fadeIn();
return false;
});
However, only the first entry in the list manages to display the message box, for other entries the page just refreshes. The message button HTML is:
<a href="" id="message" class="btn" name="<?php echo $user['userid'] .'####'. ucfirst($user['name']) ." ". ucfirst($user['first_name']." ".$user['last_name']); ?>" title="<?php echo 'Send message to ' . ucfirst($user['name']) ." ". ucfirst($user['first_name']." ".$user['last_name']); ?>">Message</a>
Upvotes: 0
Views: 502
Reputation: 6547
Updated code, use the .live(), .click() do not check for new html entry's. More info
$('#message').live("click", function(){
var str = $(this).attr('name');
var n=str.split("####");
$('#user_new').val(n[0]);
$('#msgto_username').html(n[1]);
$('#bodybg').show();
$('.confirmBox').fadeIn();
return false;
});
I hope that's what you where looking for?
Upvotes: 1