Plugin Directory

Changeset 2042047


Ignore:
Timestamp:
03/01/2019 10:58:18 AM (7 years ago)
Author:
nikolam
Message:

Fix dynamic options not saving

Location:
sermon-manager-for-wordpress/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sermon-manager-for-wordpress/trunk/assets/js/admin/settings/conditionals.js

    r2034194 r2042047  
    125125        let data = {
    126126            'action': 'sm_settings_get_select_data',
    127             'id': current_value,
     127            'category': current_value,
     128            'option_id': table_row.find( 'select' ).attr( 'id' ),
    128129        };
    129130
     
    164165                            );
    165166                            jQuery.each(
    166                                 response,
     167                                response.options,
    167168                                function ( id, item ) {
    168169                                    table_row.find( 'select' ).append( jQuery( '<option/>' ).val( id ).text( item ) );
    169170                                }
    170171                            );
     172                            if ( response.selected ) {
     173                                table_row.find( 'select' ).val( response.selected ).change();
     174                            } else {
     175                                table_row.find( 'select' ).prop( "selectedIndex", 0 );
     176                            }
    171177                            break;
    172178                    }
  • sermon-manager-for-wordpress/trunk/assets/js/admin/settings/conditionals.min.js

    r2034194 r2042047  
    1 "undefined"!=typeof sm_conditionals&&jQuery(function(){jQuery.each(sm_conditionals,function(a,b){let c=jQuery("#"+a),d=c.closest("tr");jQuery.each(b,function(a,b){let c=b.id,e=jQuery("#"+c),f=sm_isset(b.value)?b.value:b["!value"],g=sm_isset(b["!value"]);e.on("change",function(){let a=this.value;sm_hide_show_elements(f,a,g,d)}),sm_hide_show_elements(f,e.val(),g,d)})})});function sm_hide_show_elements(a,b,c,d){let e=d.find("select"),f=a!==b,g=!!e.data("ajax")&&e.data("ajax");if(f=c?!f:f,g||(f?d.addClass("hidden"):d.removeClass("hidden")),g){sm_reset_option_value(e,!d.hasClass("hidden"));jQuery.ajax({method:"POST",url:ajaxurl,data:{action:"sm_settings_get_select_data",id:b}}).always(function(){sm_reset_option_value(e,!d.hasClass("hidden"))}).done(function(a){if("false"===a)a=!1;else try{a=JSON.parse(a)}catch(b){a=!1}if("object"==typeof a)switch(d.removeClass("hidden"),e.prop("tagName")){case"SELECT":e.find("option").each(function(){jQuery(this.remove())}),jQuery.each(a,function(a,b){d.find("select").append(jQuery("<option/>").val(a).text(b))});}!1===a&&d.addClass("hidden")}).fail(function(){switch(e.prop("tabName")){case"SELECT":e.append(jQuery("<option/>").val("").text("Error."));}})}}function sm_reset_option_value(a,b){switch(a.prop("tagName")){case"SELECT":a.find("option").each(function(){jQuery(this.remove())});}b&&a.append(jQuery("<option/>").val("").text("Loading..."))}function sm_isset(a){try{return"undefined"!=typeof a}catch(a){return!1}}
     1"undefined"!=typeof sm_conditionals&&jQuery(function(){jQuery.each(sm_conditionals,function(a,b){let c=jQuery("#"+a),d=c.closest("tr");jQuery.each(b,function(a,b){let c=b.id,e=jQuery("#"+c),f=sm_isset(b.value)?b.value:b["!value"],g=sm_isset(b["!value"]);e.on("change",function(){let a=this.value;sm_hide_show_elements(f,a,g,d)}),sm_hide_show_elements(f,e.val(),g,d)})})});function sm_hide_show_elements(a,b,c,d){let e=d.find("select"),f=a!==b,g=!!e.data("ajax")&&e.data("ajax");if(f=c?!f:f,g||(f?d.addClass("hidden"):d.removeClass("hidden")),g){sm_reset_option_value(e,!d.hasClass("hidden"));let a={action:"sm_settings_get_select_data",category:b,option_id:d.find("select").attr("id")};jQuery.ajax({method:"POST",url:ajaxurl,data:a}).always(function(){sm_reset_option_value(e,!d.hasClass("hidden"))}).done(function(a){if("false"===a)a=!1;else try{a=JSON.parse(a)}catch(b){a=!1}if("object"==typeof a)switch(d.removeClass("hidden"),e.prop("tagName")){case"SELECT":e.find("option").each(function(){jQuery(this.remove())}),jQuery.each(a.options,function(a,b){d.find("select").append(jQuery("<option/>").val(a).text(b))}),a.selected?d.find("select").val(a.selected).change():d.find("select").prop("selectedIndex",0);}!1===a&&d.addClass("hidden")}).fail(function(){switch(e.prop("tabName")){case"SELECT":e.append(jQuery("<option/>").val("").text("Error."));}})}}function sm_reset_option_value(a,b){switch(a.prop("tagName")){case"SELECT":a.find("option").each(function(){jQuery(this.remove())});}b&&a.append(jQuery("<option/>").val("").text("Loading..."))}function sm_isset(a){try{return"undefined"!=typeof a}catch(a){return!1}}
  • sermon-manager-for-wordpress/trunk/sermons.php

    r2040265 r2042047  
    868868
    869869        add_action( 'wp_ajax_sm_settings_get_select_data', function () {
    870             echo json_encode( apply_filters( 'sm_settings_get_select_data', array(), $_POST['id'] ) );
     870            echo json_encode( apply_filters( 'sm_settings_get_select_data', array(), $_POST['category'], $_POST['option_id'] ) );
    871871
    872872            wp_die();
Note: See TracChangeset for help on using the changeset viewer.