announcements-4.0.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. ---
  2. layout: default
  3. title: Select2 4.0.0 Released
  4. slug: announcements-4.0
  5. ---
  6. <section id="pre-release" class="jumbotron">
  7. <div class="container">
  8. <h1>Pre-release notes</h1>
  9. <p class="lead">
  10. The 4.0 release is ready for early adopters interested in testing it out.
  11. </p>
  12. </div>
  13. </section>
  14. <div class="container s2-docs-container">
  15. <div class="row">
  16. <div class="col-md-9" role="main">
  17. <section id="release">
  18. <h1 class="page-header">Select2 4.0.0</h1>
  19. <p>
  20. The 4.0 release of Select2 is the result of three years of working on the
  21. code base and watching where it needs to go. At the core, it is a full
  22. rewrite that addresses many of the extensibility and usability problems
  23. that could not be addressed in previous versions.
  24. </p>
  25. <p>
  26. This release contains many breaking changes, but easy-upgrade paths have
  27. been created as well as helper modules that will allow for backwards
  28. compatibility to be maintained with past versions of Select2. Upgrading
  29. <em>will</em> require you to read the release notes carefully, but the
  30. migration path should be relatively straightforward. You can view a list
  31. of the most common changes that you will need to make
  32. <a href="https://github.com/select2/select2/releases">in the release notes</a>.
  33. </p>
  34. <p>
  35. Below is an in-depth review of what is new in Select2, as well as some of
  36. the major changes that have been made.
  37. </p>
  38. </section>
  39. <section id="new">
  40. <h2>New features</h2>
  41. <p>
  42. The notable features of this new release include:
  43. </p>
  44. <ul>
  45. <li>
  46. A more flexible plugin framework that allows you to override Select2 to
  47. behave exactly how you want it to.
  48. </li>
  49. <li>
  50. Consistency with standard <code>&lt;select&gt;</code> elements for all
  51. data adapters, removing the need for hidden <code>&lt;input&gt;</code>
  52. elements.
  53. </li>
  54. <li>
  55. A new build system that uses AMD to keep everything organized.
  56. </li>
  57. <li>
  58. Less specific selectors allowing for Select2 to be styled to fit the
  59. rest of your application.
  60. </li>
  61. </ul>
  62. </section>
  63. <section id="plugins">
  64. <h2>Plugin system</h2>
  65. <p>
  66. Select2 now provides interfaces that allow for it to be easily extended,
  67. allowing for anyone to create a plugin that changes the way Select2 works.
  68. This is the result of Select2 being broken into four distinct sections,
  69. each of which can be extended and used together to create your unique
  70. Select2.
  71. </p>
  72. <p>
  73. The adapters implement a consistent interface that is documented in the
  74. <a href="options.html#adapters">options section for adapters</a>, allowing
  75. you to customize Select2 to do exactly what you are looking for. Select2
  76. is designed such that you can mix and match plugins, with most of the core
  77. options being built as decorators that wrap the standard adapters.
  78. </p>
  79. </section>
  80. <section id="amd-builds">
  81. <h2>AMD-based build system</h2>
  82. <p>
  83. Select2 now uses an
  84. <a href="https://en.wikipedia.org/wiki/Asynchronous_module_definition">AMD-based build system</a>,
  85. allowing for builds that only require the parts of Select2 that you need.
  86. While a custom build system has not yet been created, Select2 is open
  87. source and will gladly accept a pull request for one.
  88. </p>
  89. <p>
  90. Select2 includes the minimal <a href="https://github.com/jrburke/almond">almond</a>
  91. AMD loader, but a custom <code>select2.amd.js</code> build is available
  92. if you already use an AMD loader. The code base (available in the
  93. <code>src</code> directory) also uses AMD, allowing you to include Select2
  94. in your own build system and generate your own builds alongside your
  95. existing infrastructure.
  96. </p>
  97. <p>
  98. The AMD methods used by Select2 are available as
  99. <code>jQuery.fn.select2.amd.define()/require()</code>, allowing you to use the
  100. included almond loader. These methods are primarily used by the
  101. translations, but they are the recommended way to access custom modules
  102. that Select2 provides.
  103. </p>
  104. </section>
  105. <section id="migrating">
  106. <h1>Migrating from Select2 3.5</h1>
  107. <p>
  108. There are a few breaking changes that migrators should be aware of when
  109. they are coming from older versions of Select2.
  110. </p>
  111. <p>
  112. If you use the full build of Select2 (<code>select2.full.js</code>), you
  113. will be automatically notified of the major breaking changes, and
  114. compatibility modules will be used in some cases to ensure that your code
  115. still behaves how you were expecting.
  116. </p>
  117. <h2 id="hidden-input">No more hidden input tags</h2>
  118. <p>
  119. In past versions of Select2, an <code>&lt;input type="hidden" /&gt;</code>
  120. tag was recommended if you wanted to do anything advanced with Select2,
  121. such as work with remote data sources or allow users to add their own
  122. tags. This had the unfortunate side-effect of servers not receiving the
  123. data from Select2 as an array, like a standard <code>&lt;select&gt;</code>
  124. element does, but instead sending a string containing the comma-separated
  125. strings. The code base ended up being littered with special cases for the
  126. hidden input, and libraries using Select2 had to work around the
  127. differences it caused.
  128. </p>
  129. <p>
  130. In Select2 4.0, the <code>&lt;select&gt;</code> element supports all core
  131. options, and support for the old
  132. <code>&lt;input type="hidden" /&gt;</code> has been removed. This means
  133. that if you previously declared an AJAX field with some pre-selected
  134. options that looked like...
  135. </p>
  136. <pre class="prettyprint linenums">
  137. &lt;input type="hidden" name="select-boxes" value="1,2,4,6" /&gt;
  138. </pre>
  139. <p>
  140. Will need to be recreated as a <code>&lt;select&gt;</code> element with
  141. some <code>&lt;option&gt;</code> tags that have <code>value</code>
  142. attributes that match the old value.
  143. </p>
  144. <pre class="prettyprint linenums">
  145. &lt;select name="select-boxes" multiple="multiple"&gt;
  146. &lt;option value="1" selected="selected"&gt;Select2&lt;/option&gt;
  147. &lt;option value="2" selected="selected"&gt;Chosen&lt;/option&gt;
  148. &lt;option value="4" selected="selected"&gt;selectize.js&lt;/option&gt;
  149. &lt;option value="6" selected="selected"&gt;typeahead.js&lt;/option&gt;
  150. &lt;/select&gt;
  151. </pre>
  152. <p>
  153. The options that you create should have <code>selected="selected"</code>
  154. set so Select2 and the browser knows that they should be selected. The
  155. <code>value</code> attribute of the option should also be set to the value
  156. that will be returned from the server for the result, so Select2 can
  157. highlight it as selected in the dropdown. The text within the option
  158. should also reflect the value that should be displayed by default for the
  159. option.
  160. </p>
  161. <h2 id="new-matcher">Advanced matching of searches</h2>
  162. <p>
  163. In past versions of Select2, when matching search terms to individual
  164. options, which limited the control that you had when displaying results,
  165. especially in cases where there was nested data. The <code>matcher</code>
  166. function was only given the individual option, even if it was a nested
  167. options, without any context.
  168. </p>
  169. <p>
  170. With the new matcher function, only the root-level options are matched and
  171. matchers are expected to limit the results of any children options that
  172. they contain. This allows developers to customize how options within
  173. groups can be displayed, and modify how the results are returned.
  174. </p>
  175. <p>
  176. A function has been created that allows old-style matcher functions to be
  177. converted to the new style. You can retrieve the function from the
  178. <code>select2/compat/matcher</code> module, which should just wrap the old
  179. matcher function.
  180. </p>
  181. <h2 id="flexible-placeholders">More flexible placeholders</h2>
  182. <p>
  183. In the most recent versions of Select2, placeholders could only be
  184. applied to the first (typically the default) option in a
  185. <code>&lt;select&gt;</code> if it was blank. The
  186. <code>placeholderOption</code> option was added to Select2 to allow users
  187. using the <code>select</code> tag to select a different option, typically
  188. an automatically generated option with a different value.
  189. </p>
  190. <p>
  191. The <code>placeholder</code> option can now take an object as well as just
  192. a string. This replaces the need for the old
  193. <code>placeholderOption</code>, as now the <code>id</code> of the object
  194. can be set to the <code>value</code> attribute of the
  195. <code>&lt;option&gt;</code> tag.
  196. </p>
  197. <p>
  198. For a select that looks like the following, where the first option (with a
  199. value of <code>-1</code>) is the placeholder option...
  200. </p>
  201. <pre class="prettyprint linenums">
  202. &lt;select&gt;
  203. &lt;option value="-1" selected="selected"&gt;Select an option&lt;/option&gt;
  204. &lt;option value="1"&gt;Something else&lt;/option&gt;
  205. &lt;/select&gt;
  206. </pre>
  207. <p>
  208. You would have previously had to get the placeholder option through the
  209. <code>placeholderOption</code>, but now you can do it through the
  210. <code>placeholder</code> option by setting an <code>id</code>.
  211. </p>
  212. <pre class="prettyprint linenums">
  213. $("select").select2({
  214. placeholder: {
  215. id: "-1",
  216. placeholder: "Select an option"
  217. }
  218. })
  219. </pre>
  220. <p>
  221. And Select2 will automatically display the placeholder when the value of
  222. the select is <code>-1</code>, which it is by default. This does not break
  223. the old functionality of Select2 where the placeholder option was blank by
  224. default.
  225. </p>
  226. <h2 id="value-ordering">Display reflects the actual order of the values</h2>
  227. <p>
  228. In past versions of Select2, choices were displayed in the order that
  229. they were selected. In cases where Select2 was used on a
  230. <code>&lt;select&gt;</code> element, the order that the server received
  231. the selections did not always match the order that the choices were
  232. displayed, resulting in confusion in situations where the order is
  233. important.
  234. </p>
  235. <p>
  236. Select2 will now order selected choices in the same order that will be
  237. sent to the server.
  238. </p>
  239. <h2 id="changed-options">Changed method and option names</h2>
  240. <p>
  241. When designing the future option set for Select2 4.0, special care was
  242. taken to ensure that the most commonly used options were brought over.
  243. For the most part, the commonly used options of Select2 can still be
  244. referenced under their previous names, but there were some changes which
  245. have been noted.
  246. </p>
  247. <h3 id="removed-initselection">
  248. Removed the requirement of <code>initSelection</code>
  249. </h3>
  250. <p>
  251. In the past, whenever you wanted to use a custom data adapter, such as
  252. AJAX or tagging, you needed to help Select2 out in determining the initial
  253. values that were selected. This was typically done through the
  254. <code>initSelection</code> option, which took the underlying data of the
  255. input and converted it into data objects that Select2 could use.
  256. </p>
  257. <p>
  258. This is now handled by
  259. <a href="options.html#dataAdapter">the data adapter</a> in the
  260. <code>current</code> method, which allows Select2 to convert the currently
  261. selected values into data objects that can be displayed. The default
  262. implementation converts the text and value of <code>option</code> elements
  263. into data objects, and is probably suitable for most cases. An example of
  264. the old <code>initSelection</code> option is included below, which
  265. converts the value of the selected options into a data object with both
  266. the <code>id</code> and <code>text</code> matching the selected value.
  267. </p>
  268. <pre class="prettyprint linenums">
  269. initSelection : function (element, callback) {
  270. var data = [];
  271. $(element.val()).each(function () {
  272. data.push({id: this, text: this});
  273. });
  274. callback(data);
  275. }
  276. </pre>
  277. <p>
  278. When using the new <code>current</code> method of the custom data adapter,
  279. <strong>this method is called any time Select2 needs a list</strong> of
  280. the currently selected options. This is different from the old
  281. <code>initSelection</code> in that it was only called once, so it could
  282. suffer from being relatively slow to process the data (such as from a
  283. remote data source).
  284. </p>
  285. <pre class="prettyprint linenums">
  286. $.fn.select2.amd.require(
  287. ['select2/data/array', 'select2/utils'],
  288. function (ArrayData, Utils) {
  289. function CustomData ($element, options) {
  290. CustomData.__super__.constructor.call(this, $element, options);
  291. }
  292. Utils.Extend(CustomData, ArrayData);
  293. CustomData.prototype.current = function (callback) {
  294. var data = [];
  295. var currentVal = this.$element.val();
  296. if (!this.$element.prop('multiple')) {
  297. currentVal = [currentVal];
  298. }
  299. for (var v = 0; v < currentVal.length; v++) {
  300. data.push({
  301. id: currentVal[v],
  302. text: currentVal[v]
  303. });
  304. }
  305. callback(data);
  306. };
  307. $("#select").select2({
  308. dataAdapter: CustomData
  309. });
  310. }
  311. </pre>
  312. <p>
  313. The new <code>current</code> method of the data adapter works in a similar
  314. way to the old <code>initSelection</code> method, with three notable
  315. differences. The first, and most important, is that <strong>it is called
  316. whenever the current selections are needed</strong> to ensure that Select2
  317. is always displaying the most accurate and up to date data. No matter
  318. what type of element Select2 is attached to, whether it supports a
  319. single or multiple selections, the data passed to the callback
  320. <strong>must be an array, even if it contains one selection</strong>.
  321. The last is that there is only one parameter, the callback to be
  322. executed with the latest data, and the current element that Select2 is
  323. attached to is available on the class itself as
  324. <code>this.$element</code>.
  325. </p>
  326. <p>
  327. If you only need to load in the initial options once, and otherwise will
  328. be letting Select2 handle the state of the selections, you don't need to
  329. use a custom data adapter. You can just create the
  330. <code>&lt;option&gt;</code> tags on your own, and Select2 will pick up
  331. the changes.
  332. </p>
  333. <pre class="prettyprint linenums">
  334. var $element = $('select').select2(); // the select element you are working with
  335. var $request = $.ajax({
  336. url: '/my/remote/source' // wherever your data is actually coming from
  337. });
  338. $request.then(function (data) {
  339. // This assumes that the data comes back as an array of data objects
  340. // The idea is that you are using the same callback as the old `initSelection`
  341. for (var d = 0; d < data.length; d++) {
  342. var item = data[d];
  343. // Create the DOM option that is pre-selected by default
  344. var option = new Option(data.text, data.id, true, true);
  345. // Append it to the select
  346. $element.append(option);
  347. }
  348. // Update the selected options that are displayed
  349. $element.trigger('change');
  350. });
  351. </pre>
  352. <h3 id="query-to-data-adapter">
  353. Custom data adapters instead of <code>query</code>
  354. </h3>
  355. <p>
  356. <a href="http://select2.github.io/select2/#data">In the past</a>, any time
  357. you wanted to hook Select2 up to a different data source you would be
  358. required to implement custom <code>query</code> and
  359. <code>initSelection</code> methods. This allowed Select2 to determine the
  360. initial selection and the list of results to display, and it would handle
  361. everything else internally, which was fine more most people.
  362. </p>
  363. <p>
  364. The custom <code>query</code> and <code>initSelection</code> methods have
  365. been replaced by
  366. <a href="options.html#dataAdapter">custom data adapters</a> that handle
  367. how Select2 stores and retrieves the data that will be displayed to the
  368. user. An example of the old <code>query</code> option is provided below,
  369. which is
  370. <a href="http://select2.github.io/select2/#data">the same as the old example</a>,
  371. and it generates results that contain the search term repeated a certain
  372. number of times.
  373. </p>
  374. <pre class="prettyprint linenums">
  375. query: function (query) {
  376. var data = {results: []}, i, j, s;
  377. for (i = 1; i < 5; i++) {
  378. s = "";
  379. for (j = 0; j < i; j++) {s = s + query.term;}
  380. data.results.push({id: query.term + i, text: s});
  381. }
  382. query.callback(data);
  383. }
  384. </pre>
  385. <p>
  386. This has been replaced by custom data adapters which define a similarly
  387. named <code>query</code> method. The comparable data adapter is provided
  388. below as an example.
  389. </p>
  390. <pre class="prettyprint linenums">
  391. $.fn.select2.amd.require(
  392. ['select2/data/array', 'select2/utils'],
  393. function (ArrayData, Utils) {
  394. function CustomData ($element, options) {
  395. CustomData.__super__.constructor.call(this, $element, options);
  396. }
  397. Utils.Extend(CustomData, ArrayData);
  398. CustomData.prototype.query = function (params, callback) {
  399. var data = {
  400. results: []
  401. };
  402. for (var i = 1; i < 5; i++) {
  403. var s = "";
  404. for (var j = 0; j < i; j++) {
  405. s = s + params.term;
  406. }
  407. data.results.push({
  408. id: params.term + i,
  409. text: s
  410. });
  411. }
  412. callback(data);
  413. };
  414. $("#select").select2({
  415. dataAdapter: CustomData
  416. });
  417. }
  418. </pre>
  419. <p>
  420. The new <code>query</code> method of the data adapter is very similar to
  421. the old <code>query</code> option that was passed into Select2 when
  422. initializing it. The old <code>query</code> argument is mostly the same as
  423. the new <code>params</code> that are passed in to query on, and the
  424. callback that should be used to return the results is now passed in as the
  425. second parameter.
  426. </p>
  427. <h3 id="changed-templating">Renamed templating options</h3>
  428. <p>
  429. Select2 previously provided multiple options for formatting the results
  430. list and selected options, commonly referred to as "formatters", using the
  431. <code>formatSelection</code> and <code>formatResult</code> options. As the
  432. "formatters" were also used for things such as localization,
  433. <a href="#changed-translations">which has also changed</a>, they have been
  434. renamed to <code>templateSelection</code> and <code>templateResult</code>
  435. and their signatures have changed as well.
  436. </p>
  437. <p>
  438. You should refer to the updated
  439. <a href="options.html#templating">documentation on templates</a> when
  440. migrating from previous versions of Select2.
  441. </p>
  442. <h3 id="changed-id">
  443. The <code>id</code> and <code>text</code> properties are strictly enforced
  444. </h3>
  445. <p>
  446. When working with array and AJAX data in the past, Select2 allowed a
  447. custom <code>id</code> function or attribute to be set in various places,
  448. ranging from the initialization of Select2 to when the remote data was
  449. being returned. This allowed Select2 to better integrate with existing
  450. data sources that did not necessarily use the <code>id</code> attribute to
  451. indicate the unique identifier for an object.
  452. </p>
  453. <p>
  454. Select2 no longer supports a custom <code>id</code> or <code>text</code>
  455. to be used, but provides integration points for converting incorrect data
  456. to the expected format.
  457. </p>
  458. <h4>
  459. When working with array data
  460. </h4>
  461. <p>
  462. Select2 previously supported defining array data as an object that matched
  463. the signature of an AJAX response. A <code>text</code> property could be
  464. specified that would map the given property to the <code>text</code>
  465. property on the individual objects. You can now do this when initializing
  466. Select2 by using the following jQuery code to map the old
  467. <code>text</code> and <code>id</code> properties to the new ones.
  468. </p>
  469. <pre class="prettyprint linenums">
  470. var data = $.map([
  471. {
  472. pk: 1,
  473. word: 'one'
  474. },
  475. {
  476. pk: 2,
  477. word: 'two'
  478. }
  479. ], function (obj) {
  480. obj.id = obj.id || obj.pk;
  481. obj.text = obj.text || obj.word;
  482. return obj;
  483. });
  484. </pre>
  485. <p>
  486. This will result in an array of data objects that have the <code>id</code>
  487. properties that match the existing <code>pk</code> properties and
  488. <code>text</code> properties that match the existing <code>word</code>
  489. properties.
  490. </p>
  491. <h4>
  492. When working with remote data
  493. </h4>
  494. <p>
  495. The same code that was given above can be used in the
  496. <code>processResults</code> method of an AJAX call to map properties there
  497. as well.
  498. </p>
  499. <h3 id="changed-translations">Renamed translation options</h3>
  500. <p>
  501. In previous versions of Select2, the default messages provided to users
  502. could be localized to fit the language of the website that it was being
  503. used on. Select2 only comes with the English language by default, but
  504. provides
  505. <a href="options.html#language">community-contributed translations</a> for
  506. many common languages. Many of the formatters have been moved to the
  507. <code>language</code> option and the signatures of the formatters have
  508. been changed to handle future additions.
  509. </p>
  510. <h3 id="changed-data">
  511. Declaring options using <code>data-*</code> attributes
  512. </h3>
  513. <p>
  514. In the past, Select2 has only supported declaring a subset of options
  515. using <code>data-*</code> attributes. Select2 now supports declaring all
  516. options using the attributes, using
  517. <a href="options.html#data-attributes">the format specified in the documentation</a>.
  518. </p>
  519. <p>
  520. You could previously declare the URL that was used for AJAX requests using
  521. the <code>data-ajax-url</code> attribute. While Select2 still allows for
  522. this, the new attribute that should be used is the
  523. <code>data-ajax--url</code> attribute. Support for the old attribute will
  524. be removed in Select2 4.1.
  525. </p>
  526. <p>
  527. Although it was not documented, a list of possible tags could also be
  528. provided using the <code>data-select2-tags</code> attribute and passing in
  529. a JSON-formatted array of objects for tags. As the method for specifying
  530. tags has changed in 4.0, you should now provide the array of objects using
  531. the <code>data-data</code> attribute, which maps to
  532. <a href="options.html#data">the array data</a> option. You should also
  533. enable tags by setting <code>data-tags="true"</code> on the object, to
  534. maintain the ability for users to create their own options as well.
  535. </p>
  536. <p>
  537. If you previously declared the list of tags as...
  538. </p>
  539. <pre class="prettyprint linenums">
  540. &lt;select data-select2-tags="[{id: '1', text: 'One', id: '2', text: 'Two'}]"&gt;&lt;/select&gt;
  541. </pre>
  542. <p>
  543. ...then you should now delare it as...
  544. </p>
  545. <pre class="prettyprint linenums">
  546. &lt;select data-data="[{id: '1', text: 'One', id: '2', text: 'Two'}]" data-tags="true"&gt;&lt;/select&gt;
  547. </pre>
  548. <h2 id="removed-methods">Deprecated and removed methods</h2>
  549. <p>
  550. As Select2 now uses a <code>&lt;select&gt;</code> element for all data
  551. sources, a few methods that were available by calling
  552. <code>.select2()</code> are no longer required.
  553. </p>
  554. <h3>.select2("val")</h3>
  555. <p>
  556. The <code>"val"</code> method has been deprecated and will be removed in
  557. Select2 4.1. The deprecated method no longer includes the
  558. <code>triggerChange</code> parameter.
  559. </p>
  560. <p>
  561. You should directly call <code>.val</code> on the underlying
  562. <code>&lt;select&gt;</code> element instead. If you needed the second
  563. parameter (<code>triggerChange</code>), you should also call
  564. <code>.trigger("change")</code> on the element.
  565. </p>
  566. <pre class="prettyprint linenums">
  567. $("select").val("1").trigger("change"); // instead of $("select").select2("val", "1");
  568. </pre>
  569. <h3>.select2("enable")</h3>
  570. <p>
  571. Select2 will respect the <code>disabled</code> property of the underlying
  572. select element. In order to enable or disable Select2, you should call
  573. <code>.prop('disabled', true/false)</code> on the
  574. <code>&lt;select&gt;</code> element. Support for the old methods will be
  575. completely removed in Select2 4.1.
  576. </p>
  577. <pre class="prettyprint linenums">
  578. $("select").prop("disabled", true); // instead of $("select").enable(false);
  579. </pre>
  580. </section>
  581. </div>
  582. <div class="col-md-3" role="complementary">
  583. {% include nav/announcements-4.0.html %}
  584. </div>
  585. </div>
  586. </div>
  587. <script type="text/javascript">
  588. prettyPrint();
  589. </script>