the jQuery function works and echoes the proper value

This commit is contained in:
jorge 2023-01-13 19:55:40 +01:00
parent 6959347849
commit 4f2630c4c1
1 changed files with 14 additions and 18 deletions

View File

@ -95,7 +95,6 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form' ) ):
(function($) {
// change
//$('#archive-filters').on('change', 'input[type="checkbox"]', function(){
$('#archive-filters').on('click', 'button', function(){
// vars
@ -109,11 +108,12 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form' ) ):
$('#archive-filters .filter').each(function(){
// check if is first appearance of each
if( eachfiltered != $(this).data('filter') ){
// save already calculated field=val01,val02,val03
appendtoURL += eachfiltered +'=' +valueschecked +'&';
// remove last ','
appendtoURL = appendtoURL.slice(0, -1);
if( eachfiltered != '' && valueschecked != '' ){
// remove last ','
valueschecked = valueschecked.slice(0, -1);
appendtoURL += eachfiltered +'=' +valueschecked +'&';
};
// start new fieldname filtered
eachfiltered = $(this).data('filter');
// reset values
@ -122,18 +122,20 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form' ) ):
$(this).find('input:checked').each(function(){
// if not empty save value and ,
if( $(this).val() != '' ){
valueschecked = $(this).val() + ',';
}
valueschecked += $(this).val() + ',';
};
});
//alert( appendtoURL +":" +eachfiltered +"=" +valuescheked);
} else {
// we have previous values checked
// find checked inputs
if( $(this).val() != '' ){
//if( $(this).val() != '' ){
// if not empty append value and ,
$(this).find('input:checked').each(function(){
valueschecked += $(this).val() + ',';
});
}
//alert( appendtoURL +":not:" +eachfiltered +"=" +valuescheked);
//};
};
});
@ -141,18 +143,12 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form' ) ):
appendtoURL += eachfiltered +'=' +valueschecked +'&';
// remove last &
appendtoURL = url.slice(0, -1);
appendtoURL = appendtoURL.slice(0, -1);
// update url
url += '?';
url += '?' +appendtoURL;
// reload page
//$('#archive-filters button').on('click', function () {
alert( "estoy en: " +url +appendtoURL);
//window.location.replace( url );
//});
alert( url );
});