mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-16 05:03:33 +09:00
- fixed select2 JS errors for the user dropdown field;
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
function um_admin_init_users_select() {
|
||||
if ( jQuery('.um-user-select-field:visible').length ) {
|
||||
if ( jQuery('.um-user-select-field:visible:not(.um-select2-inited)').length ) {
|
||||
function avatarformat( data ) {
|
||||
var option;
|
||||
if ( ! data.id ) {
|
||||
@@ -84,13 +84,15 @@ function um_admin_init_users_select() {
|
||||
templateResult: avatarformat
|
||||
};
|
||||
|
||||
jQuery('.um-user-select-field:visible').each( function() {
|
||||
let selector = jQuery('.um-user-select-field:visible:not(.um-select2-inited)');
|
||||
|
||||
selector.each( function() {
|
||||
if ( jQuery(this).hasClass('select2-hidden-accessible') ) {
|
||||
jQuery(this).select2( 'destroy' );
|
||||
jQuery(this).removeClass('um-select2-inited').select2( 'destroy' );
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('.um-user-select-field:visible').select2( select2_atts );
|
||||
selector.addClass('um-select2-inited').select2( select2_atts );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -644,8 +644,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
|
||||
$hidden = '';
|
||||
if ( ! empty( $multiple ) ) {
|
||||
$hidden = "<input type=\"hidden\" $hidden_name_attr value=\"\" />";
|
||||
} else {
|
||||
$options = '<option></option>' . $options;
|
||||
}
|
||||
$html = "$hidden<select $multiple $id_attr $name_attr $class_attr $data_attr data-placeholder=\"" . esc_attr( $placeholder ) . "\" placeholder=\"" . esc_attr( $placeholder ) . "\"><option value=\"\">" . esc_html( $placeholder ) . "</option>$options</select>";
|
||||
$html = "$hidden<select $multiple $id_attr $name_attr $class_attr $data_attr data-placeholder=\"" . esc_attr( $placeholder ) . "\" placeholder=\"" . esc_attr( $placeholder ) . "\">$options</select>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user