Autor | Zpráva | ||
---|---|---|---|
HGD Profil |
#1 · Zasláno: 6. 3. 2016, 17:53:19
Ahoj, mám kód, který přidává do tabulky řádek, ale potřeboval bych předat proměnnou, jenže "onclick" mi nefunguje. Kde dělám chybu?
HTML <table class="widefat" id="Mytab"> <thead style="2px solid #eee;"> <tr> <th class="sort" width="1%"> </th> <th><?php _e( 'ID-name ohne interpunkt', 'wc-bookings-rental' ); ?></th> <th><?php _e( 'Name', 'wc-bookings-rental' ); ?></th> <th><?php _e( 'Max. block', 'wc-bookings-rental' ); ?> <a class="tips" data-tip="<?php _e( 'Please select the date range for which you want the product to be disabled.', 'uou-bookings' ); ?>">[?]</a></th> <th class="remove" width="1%"> </th> </tr> </thead> <tfoot> <tr> <th colspan="5"> <a href="#" class="button button-primary add_row"><?php _e( 'Add Range', 'wc-bookings-rental' ); ?></a> <p class="button button-primary" onclick="addRow()"><?php _e( 'Add Row', 'wc-bookings-rental' ); ?></p> </th> </tr> </tfoot> <tbody id="availability_rows"> <?php include( 'uou-resource-booking-availability-fields.php' ); ?> </tbody> </table> JS první blok funguje, druhý nevím kde je chyba :) // přidání řádku $( '.add_row' ).click(function(){ var index = 3; $(this).closest('table').find('tbody').append(copy_row(index)); $('body').trigger('row_added'); return false; }); // přidání řádku function addRow(){ $(this).closest('table').find('tbody').append('<tr><td>HELE</td></tr>'); return false; } |
||
_es Profil |
#2 · Zasláno: 6. 3. 2016, 18:23:26
|
||
HGD Profil |
#3 · Zasláno: 6. 3. 2016, 18:35:55
takže teoreticky by mělo fungovat tohle?
$('#Mytab').find('tbody').append('<tr><td>HELE</td></tr>'); |
||
_es Profil |
#4 · Zasláno: 6. 3. 2016, 18:44:59
HGD:
No ale chcel si snáď radu, aby oba kódy fungovali rovnako. V HTML atribúte onclick zavoláš funkciu addRow takto:
onclick="addRow(this)" function addRow(element){... this budeš pracovať s premennou element .
|
||
Časová prodleva: 9 let
|
0