php - Lazy Load Select2 Mulitselect -


i have huge mulitselect list of on 29,000 options on page. displaying them in form using select2, because there many options slows down page drastically. know select2 supports lazy load, not sure how implement in form.

i using code in functions.php add select dropdown form (only showing couple options rest not necessary)

 add_filter( 'submit_job_form_fields', 'frontend_add_experience_field' );  function frontend_add_experience_field( $fields) { $fields['job']['regions1'] = array( 'label'       => __( 'farming areas', 'job_manager' ), 'type'        => 'multiselect', 'required'    => true, 'name' => 'regions1', 'placeholder' => 'select city', 'priority'    => 8, 'options'     => array(  "abanda, al"=>"abanda, al", "abbeville, al"=>"abbeville, al", "adamsville, al"=>"adamsville, al", "addison, al"=>"addison, al", "akron, al"=>"akron, al", "alabaster, al"=>"alabaster, al", "albertville, al"=>"albertville, al", "alexander, al"=>"alexander, al", "alexandria, al"=>"alexandria, al", "aliceville, al"=>"aliceville, al",  ));    return $fields; } 

and javascript implement select2

<script>  jquery(function($) { $(document).ready(function() {  $("#regions1").select2({       placeholder: "search city", minimuminputlength: 4, maximumselectionlength: 4, width: "200px",  }); }); });  </script> 

seeing on page there around 29,000 options, lazy load best way implement select2 or there more efficient way of displaying results without putting huge load on server?

thank in advance.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -