Skip to content

Commit

Permalink
Fix: Conditions not working for form fields (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
NiclasNorin authored Oct 19, 2023
1 parent 92706a2 commit 080c9e8
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions source/js/admin/conditional-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@ export default (function ($) {
selected = $selected.val();
} else {
// Get selected from database
var fieldName = $(element).attr('name');
$.ajax({
url: ajaxurl,
type: 'post',
data: {
action : 'get_selected_field',
moduleId : modularity_current_post_id,
fieldName : fieldName
},
success: function(response) {
if (response != 'error') {
$("option[value='" + response + "']", element).prop('selected', true);
}
}
});
if (typeof modularity_current_post_id !== 'undefined') {
var fieldName = $(element).attr('name');
$.ajax({
url: ajaxurl,
type: 'post',
data: {
action : 'get_selected_field',
moduleId : modularity_current_post_id,
fieldName : fieldName
},
success: function(response) {
if (response != 'error') {
$("option[value='" + response + "']", element).prop('selected', true);
}
}
});
}
}

// Reset select options
Expand Down

0 comments on commit 080c9e8

Please sign in to comment.