Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [jQuery] usuwanie wpisow
palonek
post 25.08.2009, 09:59:25
Post #1





Grupa: Zarejestrowani
Postów: 32
Pomógł: 2
Dołączył: 19.04.2009

Ostrzeżenie: (0%)
-----


witam



zrobiłem sobie usuwanie wpisów z shoutboxa. Problem tkwi w tym ze kod wywołuje $('.del').click(); , divow z tymi klasami jest kilka, i skrypt usuwa nie ten w ktory sie kliknie tylko ostatni dodany:



[JAVASCRIPT] pobierz, plaintext
  1. $(document).ready(function() {
  2.  
  3.  $('.del').click(function() {
  4.  var loading = $('#loading');
  5.  var messageList = $('.content > ul');
  6.  var id = $('.delete').attr('id');
  7.  
  8.  
  9.   messageList.fadeOut();
  10.   loading.fadeIn();
  11.  
  12.   $.ajax({
  13.   type: 'POST', url: 'shoutbox.php', data: 'action=delete&id=' + id,
  14.   complete: function(data){
  15.  
  16.   $.ajax({
  17.   type: 'POST', url: 'shoutbox.php', data: 'action=update',
  18.   complete: function(data){
  19.   loading.fadeOut();
  20.   messageList.html(data.responseText);
  21.   messageList.fadeOut();
  22.   messageList.fadeIn(2000);
  23.   }
  24.   });
  25.   }
  26.   });
  27.  });
  28. }); 
  29.  
[JAVASCRIPT] pobierz, plaintext


  1.  
  2.   while($row = mysql_fetch_array($res)){
  3.   echo "<div class='contentin'><span class='shoutbox_nick'><b>".$row['user']." </b></span> <span class=\"date\"> ".$row['date']."</span><br /><span class=\"message\">".$row['message']."</span>";
  4.   if($_SESSION['ranga'] == 3){
  5.   echo "<div class='del'><a href='#usunWpis' class='delete' id='".$row['id']."'>[Usun]</a></div>";
  6.   }
  7.   echo "</div>";
  8.  



Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 05:57