|
Что то не так с кодом
$('.delete').click(function(e) {
e.preventDefault();
var id = $(this).attr('id');
$('.n_warning').fadeOut(500);
$('.n_warning').fadeIn(500);
$('.n_warning').html('<p>Are you sure? <button id=\"yes\">YES</button><button id=\"no\">NO</button></p>');
$('#yes').click(function(){
$.ajax({
type: 'POST',
url: '/admin/delete',
data: {
id:id
},
success: function(data){
$('#'+id).fadeOut(500);
$('#adm-notification').html(data);
}
});
});
$('#no').click(function(){
$('.n_warning').fadeOut(500);
});
});
Код вроде бы работает, все отлично. Но вот сделал один раз (т.е кликнул на .delete потом на #yes, отправил ajax, удалил из базы) после этого больше .delete не кликается, соответвенно .n-warning не появляется. В чем проблема? |
Консоль браузера наверно для лохов придумали, правда?
|
Консоль чист...
|
.delete случайно не внутри #adm-notification находится?
|
Нет, вот код.
<div id="adm-notification">
<div class="n_warning"><p></p></div>
<div class="n_ok"><p></p></div>
<div class="n_error"><p></p></div>
</div>
<table>
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Category</th>
<th scope="col">Title</th>
<th scope="col">Image</th>
<th scope="col">Short</th>
<th scope="col">Date</th>
<th scope="col">Lang</th>
<th scope="col" style="width: 65px;">Modify</th>
</tr>
</thead>
<tbody>
<?php
while($result_main_arm = mysql_fetch_array($query_main_arm)){
print "
<tr id=".$result_main_arm['id'].">
<td class=\"align-center\">".$result_main_arm['id']."</td>
<td class=\"align-center\">".$result_main_arm['category']."</td>
<td class=\"align-center\">".$result_main_arm['title']."</td>
<td class=\"align-center\">".$result_main_arm['img']."</td>
<td class=\"align-center\">".$result_main_arm['short_content']."</td>
<td class=\"align-center\">".$result_main_arm['date']."</td>
<td class=\"align-center\">".$result_main_arm['lang']."</td>
<td>
<a href=\"/admin/edit?id=".$result_main_arm['id']."&lang=".$result_main_arm['lang']."\" class=\"table-icon edit\" title=\"Edit\"></a>
<a href=\"/admin/delete?id=".$result_main_arm['id']."&lang=".$result_main_arm['lang']."\" id=".$result_main_arm['id']." class=\"table-icon delete\" title=\"Delete\"></a>
</td>
</tr>
";
}
|
повесьте событие таким образом:
$(document).on('click', '.delete', function(e) {
вместо:
$('.delete').click(function(e) {
|
Цитата:
|
Цитата:
Цитата:
|
Цитата:
|
Цитата:
|
| Часовой пояс GMT +3, время: 20:20. |
|