I'd like to develop a setting/control for Customizer that allows dynamically to add fields. The typical example would be the possibility to add an unlimited number of slides to an slider in a Theme. There would be a button in the Customizer setting called "Add new slide" that allows to add a new slide field.
For the sake of the responses, let's make it easy: Just a text field per row. So each time we click on a "Add new row" button, a new text field is generated.
I've tried different approaches and my latest one was an attempt to use script templates (Mustache) like this example:
The problem is how to handle dynamically those settings? How to use the WP_Customize_Control to_json function and how to get that Mustache template and duplicate it every time we click on the "Add new" button? I have a very good background on PHP and a medium level on JS so I can understand advanced topics.
I'd like to develop a setting/control for Customizer that allows dynamically to add fields. The typical example would be the possibility to add an unlimited number of slides to an slider in a Theme. There would be a button in the Customizer setting called "Add new slide" that allows to add a new slide field.
For the sake of the responses, let's make it easy: Just a text field per row. So each time we click on a "Add new row" button, a new text field is generated.
I've tried different approaches and my latest one was an attempt to use script templates (Mustache) like this example: http://justintadlock/archives/2015/06/05/javascript-templating-in-the-wordpress-customizer
The problem is how to handle dynamically those settings? How to use the WP_Customize_Control to_json function and how to get that Mustache template and duplicate it every time we click on the "Add new" button? I have a very good background on PHP and a medium level on JS so I can understand advanced topics.
Share Improve this question asked Aug 31, 2015 at 17:06 IgnacioIgnacio 711 silver badge3 bronze badges2 Answers
Reset to default 6You could use or take a reference from Kirki. It is a framework that allow to add customizer controls with less code.
Take a look to Kirki::Repeater_Control here.
This is awesome,have a look it's the best https://github/cristian-ungureanu/customizer-repeater
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745361357a4624375.html
评论列表(0条)