Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jQuery UI Datepicker in dynamic form

Featured Replies

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.

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.