Skip to content

Instantly share code, notes, and snippets.

@monishdeb
Last active October 13, 2017 13:15
Show Gist options
  • Save monishdeb/5ca2417d11a31f0b65727a0da1dfe105 to your computer and use it in GitHub Desktop.
Save monishdeb/5ca2417d11a31f0b65727a0da1dfe105 to your computer and use it in GitHub Desktop.

select2 4.0.4 compatibility issues with CiviCRM

Major issues:

  1. Auto appending values doesn't work anymore Error: Uncaught TypeError: Cannot read property 'prop' of undefined LOC - https://github.com/civicrm/civicrm-core/blob/master/js/crm.searchForm.js#L9 As per 3.5 - $('#select2').select2().select2('val', 2) As per 4.0.4 - $('#select2').val([1,2]).trigger('change'); Reference - https://select2.org/upgrading/migrating-from-35#select2-val

  2. Placeholder broken Error: Uncaught TypeError: Cannot read property 'id' of undefined
    As per 3.5 - placeholderOption is used to set the placeholder value for select2 widget As per 4.0.4 - placeholder option can now accept placeholder value both in string and object Reference - https://select2.org/upgrading/migrating-from-35#more-flexible-placeholders

  3. EntityRef select2 fields are broken Error: Uncaught Error: No select2/compat/initSelection As per 4.0.4 - Removed the requirement of 'initSelection' Reference - https://select2.org/upgrading/migrating-from-35#removed-the-requirement-of-initselection

  4. Navigation menu style is not applied Error: Uncaught TypeError: Cannot read property 'prop' of undefined As per 4.0.4 - $("select").val("1").trigger("change"); // instead of $("select").select2("val", "1"); Reference - https://select2.org/upgrading/migrating-from-35#select2-val

Minor issues

  1. Multi select2 widget doesn't show downarrow placeholder icon
  2. select2 css style aren't applied after upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment