Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to override minified JavaScript functions
    text
    copied!<p>Is it possible to override functions contained in a minified Javascript file?</p> <p>Details: I'm attempting to override the process() function within the Twitter Boootstrap Typeahead plugin (v2.3.2) in order to add an indicator at the bottom of the drop-down if items returned exceed the items displayed.</p> <p>Here is my code:</p> <pre><code>var customProcess = function (items) { var that = this items = $.grep(items, function (item) { return that.matcher(item) }) items = this.sorter(items) if (!items.length) { return this.shown ? this.hide() : this } //Get the default item slice and determine whether the indicator is needed var itemSlice = items.slice(0, this.options.items); if (items.length &gt; this.options.items) { itemSlice.push("..."); } return this.render(itemSlice).show(); }; // Reassign the typeahead.process() function to the customized // version that adds a visual indicator if more items are // returned than the amount shown (options.items). $.fn.typeahead.Constructor.prototype.process = customProcess; </code></pre> <p>If I'm using the minified version of the Bootstrap JavaScript (bootstrap.min.js) this fails and actually kills the typeahead functionality completely. If I instead source the non-minified version (bootstrap.js), it works perfectly. </p> <p>[As a side note, I previously used the same approach with an older version of the typeahead plugin (v1.8.x I believe) and it worked perfectly with the minimized version as well. Did I just get lucky?]</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload