Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> brak dostępu do elementu DOM po append()
john_doe
post
Post #1





Grupa: Zarejestrowani
Postów: 873
Pomógł: 25
Dołączył: 24.07.2005

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


Cześć,

mam dwie tabelki. Przerzucam wiersz z jednej do drugiej -> o tym była mowa TUTAJ
W tej drugiej tabelce dodałem przycisk, którym wyzwalam bootstrap modal i przenoszę na niego jedną wartość do forma w taki sposób
  1. $('#fatteningElements').on('click', '.edit-element', function(event) {
  2. event.preventDefault();
  3.  
  4. resetModalFormErrors( '#quantity-form' );
  5.  
  6. var positionId = $(this).attr('data-id');
  7. var quantity = $.trim($(this).closest('tr').find('.quantity').html());
  8.  
  9. $('input[name="id"]').val(positionId);
  10. $('#quantity').val(quantity).attr('max', quantity);
  11. $('#quantity').focus();
  12.  
  13. });


klikam w submit

  1. $('#quantity-form').on('submit', function (e) {
  2. e.preventDefault(e);
  3.  
  4. var url = $( this ).attr('action');
  5. var $form = $( this );
  6.  
  7. $.ajax({
  8.  
  9. type: "post",
  10. url: url,
  11. data: $(this).serialize(),
  12. success: function (data) {
  13. var row = $('#fatteningElements').find($('#fatteningelements_async_content tr[data-row="'+data.id+'"]')); // I TUTAJ JEST KICHA, NIE MOGĘ TEGO W TEN SPOSÓB ZNALEŹĆ
  14. row.find('.quantity').text(data.quantity);
  15. }
  16. })
  17. });


kiedy wyświetlę tą tabelkę prosto z bazy powyższy kod na sumbit działa. Generalnie co się źle dzieje? Po submicie update leci ładnie do bazki ale chce tą wartość w komórce nadpisać tą nową.

wrzuce jeszce html tej tabelki
  1. <table id="fatteningElements" class="table m-table--head-no-border table-hover m-table table-responsive">
  2. <tr>
  3. <th>List</th>
  4. <th>Ilość</th>
  5. <th>Akcje</th>
  6. </tr>
  7. </thead>
  8. <tbody id="fatteningelements_async_content">
  9.  
  10. <tr data-row="56">
  11. <td><i class="fa fa-mars"></i> BUT 6</td>
  12. <td class="quantity">1</td>
  13. <td>
  14. <a href="#" class="btn btn-success m-btn m-btn--icon btn-sm m-btn--icon-only edit-element" data-toggle="modal" data-target="#m_modal_quantity" data-id="56">
  15. <i class="la la-edit"></i>
  16. </a>
  17. <a href="#" class="btn btn-danger m-btn m-btn--icon btn-sm m-btn--icon-only delete-element" data-id="56">
  18. <i class="la la-trash"></i>
  19. </a>
  20. </td>
  21. </tr>
  22. <tr data-row="71">
  23. <td><i class="fa fa-venus"></i> BUT 7</td>
  24. <td class="quantity">12</td>
  25. <td>
  26. <a href="#" class="btn btn-success m-btn m-btn--icon btn-sm m-btn--icon-only edit-element" data-toggle="modal" data-target="#m_modal_quantity" data-id="71">
  27. <i class="la la-edit"></i>
  28. </a>
  29. <a href="#" class="btn btn-danger m-btn m-btn--icon btn-sm m-btn--icon-only delete-element" data-id="71">
  30. <i class="la la-trash"></i>
  31. </a>
  32. </td>
  33. </tr>
  34.  
  35. </tbody>
  36. </table>


Ten post edytował john_doe 19.03.2018, 14:38:47
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 Aktualny czas: 21.08.2025 - 09:08