Opal-Estate-Pro/inc/vendors/cmb2-plugins/custom-fields/user/assets/script.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-09-25 10:34:38 +02:00
(function( $ ) {
'use strict';
$( document ).ready( function() {
$( ".adduser-team" ).delegate( ".remove-user", "click", function() {
if( confirm( $(this).data('alert') ) ){
$(this).parents( '.user-team' ).remove();
}
});
$( '.opalestate-add-user-field' ).each( function() {
var $this = $(this);
$('.button', this).click( function () {
var user_search = $( '.opalestate-adduser-search', $(this).parent().parent() ).val();
$('.opalestate-ajax').show();
var data = {
action: 'opalestate_ajax_search_username',
user_name: user_search,
};
$.ajax({
type: "POST",
data: data,
dataType: "json",
url: ajaxurl,
success: function ( response ) {
if( response.status == true ){
var template = wp.template( 'adduser-team-template' );
$('.adduser-team', $this ).append( template( response.user ) );
}else {
alert( response.message );
}
}
});
} );
} );
} );
})( jQuery );