I’m having a hard time figuring out why my repeatable fields javascript doesn’t work. I’m using the following plugin: Rhyzz (repeatable-fields): http://www.rhyzz.com/repeatable-fields.html. I scraped the website and I see he ran the script inside html and also ran his javascript all on the same page. My website is a lot larger. I’m using WordPress and I did the following to call the script in functions.php
.
wp_enqueue_script( 'jquery', 'https://code.jquery.com/jquery-1.11.2.min.js', array(), '20120206', true );
wp_enqueue_script( 'jquery-ui', 'https://code.jquery.com/ui/1.11.4/jquery-ui.min.js', array(), '20120206', true );
wp_enqueue_script( 'jquery-repeatable', get_template_directory_uri() . '/js/repeatable.js', array( 'jquery', 'jquery-ui' ), '20120206', true );
I also have about another 10 scripts. The files are all in the proper directories. I then have a particular page on my site (PHP) implementing the repeatable fields, but none of the buttons work. I don’t have the following anywhere, and I don’t know if it’s necessary, but on Rhyzz’s site he puts it in his HTML:
jQuery(function() {
jQuery('.repeat').each(function() {
jQuery(this).repeatable_fields();
});
});
I’m very frustrated and don’t know what to do. I also don’t know if I’m enqueueing the script properly, as in if I should pass in jquery and jquery-ui into the array field. If anyone can help me with this please do so!
Note: This is Rhyzz’s GitHub with a tutorial on how to implement in HTML, https://github.com/Rhyzz/repeatable-fields.