Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> wyswietl obrazek po kliknieciu wiersza
robert1974
post
Post #1





Grupa: Zarejestrowani
Postów: 131
Pomógł: 1
Dołączył: 2.11.2014

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


czesc.

w php generuje tabele z wierszami. jedna z kolumn jest link do obrazka, jak sie kliknie to sie obrazek wyswitla, .... ale
chcialbym gdy uzytkownik kliknie na jakims wierszu (ktorejkolwiek kolumnie) by pojawial sie obrazek z danego wiersza.

znalazlem taki kawalek kodu ktory mam nadzieje ze jest pomocny, choc go do konca nie rozumiem (IMG:style_emoticons/default/sad.gif)

1. uzywam klasy hidden, ktora :
.hidden{
display: none;
}

2. przy tworzniu tablicy uzywam tego hidden by nie pokazac linku
echo '<td style="width:240px"> <a href="sigfiles/'.$myimg.'" class="hidden">PIC LINK</a></td>';

choc w sumie to chyba lepiej uzyc tej klasy w tagu TD, by wcale kolumny z linkiem nie pokazywac. teraz pokazuje sie pusta kolumna.

3. i teraz jest taki kod:

$('table').on('click', 'tr', function(){
var a = $(this).find('.hidden');
a.trigger('click');

ktory z tego co rozumiem przechwytuje event klikniecia w wiersz tabeli, szuka co jest klasy hidden (czyli ten moj img), i trigeruje click, czyli jesli dobrze rozumiem, to powinno dzialac tak samo jakbym kliknal samemu w ten ukryty link. niestety na ta chwile nie dziala (IMG:style_emoticons/default/sad.gif) ...i nie wiem czy wogole tedy droga

dzieki.

Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
robert1974
post
Post #2





Grupa: Zarejestrowani
Postów: 131
Pomógł: 1
Dołączył: 2.11.2014

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


ja tego tez nie rozumiem (IMG:style_emoticons/default/sad.gif) , .... ale kod ktory dziala wyglada tak:

  1. function drawResults(){
  2. to=0;
  3. $.ajax({
  4. url: 'ajax/ajax_reload.php',
  5. type: 'post',
  6. data: {reload: 'reload'},
  7. // dataType: 'JSON',
  8. success: function(msg){
  9. msg = $.parseJSON(msg);
  10. $('#results').empty();
  11. var highlighted=0;
  12. var patt = '';
  13. var ii=0;
  14. $.each(msg, function(k,v){
  15.  
  16. if(ii<5){
  17. var sou = v.sounds.split('-');
  18. $.each(sou, function(k, v){
  19.  
  20. if($('#play-sound').is(':checked')) playSound(v);
  21. console.log('v => '+v);
  22. });
  23.  
  24. }
  25.  
  26. //DLA KAZDEGO PRZETWÓRZ DATY
  27. if(v.signal_dir == -1) var arrow = "<img src='images/down.png'>";
  28. else var arrow = "<img src='images/up.png'>";
  29.  
  30.  
  31. if(v.highlight == 1){
  32. var style = ' style="background: #BB86A6"';
  33. patt = v.instrument;
  34. highlighted++;
  35. }
  36. else var style = '';
  37.  
  38. // console.log(v.highlight);
  39.  
  40. var html = '<tr class="result" '+style+'><td class="instrument">'+v.instrument+' '+v.id+'</td><td class="tf">'+v.tf+'</td><td class="signame">'+v.signal_name+'</td><td class="sigdir">'+arrow+'</td><td class="sigbarno">'+v.signal_barno+'</td><td class="updatedtime">'+convertDate(v.last_updated_time)+'</td><td class="exptime">'+convertDate(v.exp_time)+'</td><td>'+convertDate(v.last_updated_time)+'<a href="sigfiles/'+v.img+'" class="hidden" rel="prettyPhoto">xxx</a></td></tr>';
  41. $('#results').append(html);
  42. document.title
  43. $("a[rel^='prettyPhoto']").prettyPhoto({social_tools: false});
  44.  
  45. ii++;
  46.  
  47. });
  48. to=0;
  49. if(highlighted > 0) document.title= '('+highlighted+') '+patt;
  50. else document.title='0';
  51. },
  52. error: function(msg){
  53. // alert('Wystąpił błąd, proszę odświeżyć stronę.');
  54. location.reload();
  55. }
  56. });
  57.  
  58. }
  59.  


i sprawdzilem ze jesli zrobie ten warunek:

  1. if(ii<2)
  2. {
  3. $("a[rel^='prettyPhoto']").prettyPhoto({social_tools: false});
  4. }


to klikalne/otwierane w prettyPhoto beda tylko 2 pierwsze wiersze.
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 12.10.2025 - 00:11