forked from mfields/Taxonomy-Images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit-tags.js
32 lines (30 loc) · 1.07 KB
/
edit-tags.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
jQuery( document ).ready( function( $ ) {
$( 'body' ).on( 'click', '.taxonomy-image-control a', function () {
taxonomyImagesPlugin.tt_id = parseInt( $( this ).parent().find( 'input.tt_id' ).val() );
taxonomyImagesPlugin.term_name = $( this ).parent().find( 'input.term_name' ).val();
taxonomyImagesPlugin.image_id = parseInt( $( this ).parent().find( 'input.image_id' ).val() );
} );
$( 'body' ).on( 'click', '.taxonomy-image-control .remove', function () {
$.ajax( {
url: ajaxurl,
type: "POST",
dataType: 'json',
data: {
'action' : 'taxonomy_image_plugin_remove_association',
'wp_nonce' : taxonomyImagesPlugin.nonce,
'tt_id' : taxonomyImagesPlugin.tt_id
},
cache: false,
success: function ( response ) {
if ( 'good' === response.status ) {
$( '#remove-' + taxonomyImagesPlugin.tt_id ).addClass( 'hide' );
$( '#taxonomy_image_plugin_' + taxonomyImagesPlugin.tt_id ).attr( 'src', taxonomyImagesPlugin.img_src );
}
else if ( 'bad' === response.status ) {
alert( response.why );
}
}
} );
return false;
} );
} );