Testmating

Test out to see how your future breeding is going to work out!
Sire:
Dam:
// In your Javascript (external .js resource or tag)
jQuery(document).ready(function($) {
$('.js-example-basic-single').select2();
jQuery(".show-testmating").click( function(e) {
e.preventDefault();
sire = jQuery(".sire-select").val()
dam = jQuery(".dam-select").val()
jQuery.ajax({
type : "post",
dataType : "json",
url :ajaxurl,
data : {action: "showtestmating", sire : sire , dam : dam},
success: function(response) {
if(response.type == "success") {
console.log(response);
jQuery(".testmating-tree-wrapper").html(response);
jQuery(".testmating-tree-wrapper").show();
$('html, body').animate({
scrollTop: $(".testmating-tree-wrapper").offset().top
}, 1000)
}
else {
console.log(response);
jQuery(".testmating-tree-wrapper").html(response);
jQuery(".testmating-tree-wrapper").show();
$('html, body').animate({
scrollTop: $(".testmating-tree-wrapper").offset().top
}, 1000)
}
}
})
})
});
jQuery(function($){
// simple multiple select
$('#rudr_select2_tags').select2();
// multiple select with AJAX search
$('.js-example-basic-single').select2({
ajax: {
url: ajaxurl, // AJAX URL is predefined in WordPress admin
dataType: 'json',
delay: 250, // delay in ms while typing when to perform a AJAX search
data: function (params) {
return {
q: params.term, // search query
action: 'mishagetposts' // AJAX action for admin-ajax.php
};
},
processResults: function( data ) {
var options = [];
if ( data ) {
// data is the array of arrays, and each of them contains ID and the Label of the option
$.each( data, function( index, text ) { // do not forget that "index" is just auto incremented value
options.push( { id: text[0], text: text[1] } );
});
}
return {
results: options
};
},
cache: true
},
minimumInputLength: 3 // the minimum of symbols to input before perform a search
});
});

