[jQuery] ISSUE - Multiple click events on single click
Hello,
I'm not sure if anyone can help me with this issue, but I'll put it
out there and see. I have a page that displays a company's
information along with a list of the contacts for that company. There
could be anywhere from 0 to infinity number of contacts, and each one
has an 'Edit' button to allow the user to edit that contacts
information. When the user clicks the edit button, a box with a form
pops up (jQuery Impromptu) with the information.
The issue that I am having is that when the user goes on to click
another contacts edit button, the popup will double each time. For
example, if the user has already click 1 time, and clicks a second
time, there will be 2 forms. On the 3rd click there will be 4 forms,
and so on.
Here is a snippet of my code:
HTML:
<tr>
<td><input type="checkbox"></td>
<td>Lucas Hibbard</td>
<td>BLAH</td>
<td><a href="#">BLAH</a></td>
<td>123</td>
<td>
<a class="edit" id="cContactEdit" rel="1" href="">edit</a>
<a class="delete" id="cContactDelete" rel="1" href="">delete</a>
</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>Ed Orsini</td>
<td>BLAH</td>
<td><a href="#">BLAH</a></td>
<td>123</td>
<td>
<a class="edit" id="cContactEdit" rel="2" href="">edit</a>
<a class="delete" id="cContactDelete" rel="2" href="">delete</a>
</td>
</tr>
JQuery:
$(".edit").click(function(e) {
e.preventDefault();
var action = this.id;
.
.
.
if (action == 'cContactEdit') {
var id = this.rel;
$.get(base_url + 'index.php/ajax/edit/cContact/' + id, function
(data) {
$.prompt(data, {
callback: saveContactEdit,
buttons: { Save: true, Cancel: false }
});
});
}
Please help! If you need more information, just let me know.
Thank you,
Lucas