WP-tools/import-csv2cpt/js/import-csv2cpt-acf-input.js

90 lines
2.7 KiB
JavaScript
Raw Permalink Normal View History

jQuery(document).ready(function($) {
});
/*
* Button: Ajax Data
*
* @Json data Ajax data
* @jQuery $el jQuery field element
*/
// filter('acfe/fields/button/data', data, $el);
// filter('acfe/fields/button/data/name=importer', data, $el);
// filter('acfe/fields/button/data/key=field_6213688a5f49e', data, $el);
// acf.addFilter('acfe/fields/button/data/name=importer_csv_data', function(data, $el){
acf.addFilter('acfe/fields/button/data/key=field_button_import_csv2cpt', function(data, $el){
console.log('data function');
console.log(data);
data.custom_key = 'value';
return data;
});
/*
* Button: Before Ajax Request
*
* @jQuery $el jQuery field element
* @Json data Ajax data
*/
// action('acfe/fields/button/before', $el, data);
// action('acfe/fields/button/before/name=importer', $el, data);
// action('acfe/fields/button/before/key=field_6213688a5f49e', $el, data);
// acf.addAction('acfe/fields/button/before/name=importer_csv_data', function($el, data){
acf.addAction('acfe/fields/button/before/key=field_button_import_csv2cpt', function( $el, data){
// log arguments
console.log('before function');
console.log($el);
console.log(data);
});
/*
* Button: Ajax Success
*
* @jQuery $el jQuery field element
* @Json data Ajax data
*/
// action('acfe/fields/button/success', response, $el, data);
// action('acfe/fields/button/success/name=importer', response, $el, data);
// action('acfe/fields/button/success/key=field_6213688a5f49e', response, $el, data);
// acf.addAction('acfe/fields/button/success/name=importer_csv_data', function(response, $el, data){
acf.addAction('acfe/fields/button/success/key=field_button_import_csv2cpt', function(response, $el, data){
console.log('success');
// json success was sent
if(response.success){
// log arguments
console.log($el);
console.log(data);
}
});
/*
* Button: Ajax Complete
*
* @jQuery $el jQuery field element
* @Json data Ajax data
*/
// action('acfe/fields/button/complete', response, $el, data);
// action('acfe/fields/button/complete/name=importer', response, $el, data);
// action('acfe/fields/button/complete/key=field_6213688a5f49e', response, $el, data);
// acf.addAction('acfe/fields/button/complete/name=importer_csv_data', function(response, $el, data){
acf.addAction('acfe/fields/button/complete/key=field_button_import_csv2cpt', function(response, $el, data){
console.log('complete');
// parse json response
response = JSON.parse(response);
console.log(response);
console.log($el);
console.log(data);
});