September 10, 201412 yr I have a dynamic form with a repeatable field. The script for the repeatable field is this one // Insert new table row $('#wprm_add_date_to_exclude').on('click', function() { var row = $('#wprm_dates_to_exclude tr:last'); var clone = row.clone(); var count = row.parent().find( 'tr' ).length; clone.find( 'td input' ).val( '' ); clone.find( 'input, select' ).each(function() { var name = $( this ).attr( 'name' ); name = name.replace( /\[(\d+)\]/, '[' + parseInt( count ) + ']'); $( this ).attr( 'name', name ).attr( 'id', name ); }); clone.insertAfter( row ); return false; }); // Remove table row $('body').on('click', '#wprm_dates_to_exclude .wprm_remove_date_to_exclude', function() { if( confirm( wprm_admin_js_settings.delete_table ) ) $(this).closest('tr').remove(); return false; }); But i can't figure out how to dynamically add the datepicker to the newly created field, i've googled it and found many articles about it, but none of the solutions worked, any idea how to fix this issue? Thank you.
September 14, 201412 yr can't you just use <input type="date"> ? On all the modern browsers this will generate a datepicker and on mobiles it will use the phones native datepicker too. Only issue for old browsers is they have to manually type it in, but useage in these browsers is dwindling and I think it's worth the hit for a better UI on mobiles. The jQuery UI datepicker isn't the easiest thing to work with although I am sure it's possible to do what you're looking for I'm not exactly sure how, but going with the date form element that should be straightforward to add to your repeater.
Create an account or sign in to comment