Custom JavaScript


I have a question that I think applies to Omeka in general and not only to the Faceted Browse module.

I’d like to add select2 to my Faceted Browse page. I have downloaded the code and put int the Faceted Browse assets directory. Then added the following to FacetedBrowse/view/faceted-browse/site/page/page.phtml

$this->headLink()->appendStylesheet($this->assetUrl('css/site/select2.min.css', 'FacetedBrowse'));
$this->headScript()->prependFile($this->assetUrl('js/select2.min.js', 'FacetedBrowse'));
$this->headScript()->appendFile($this->assetUrl('js/select2Fields.js', 'FacetedBrowse'));

In the latter I put my initialisation script for my single fields, e.g.:

$(document).ready(function() {

The scripts are loaded indeed and in the correct order (select2 first, then my script), and launching $('.date-before-value').select2() in my browser’s console changes the field to a select2 field. Nevertheless when the page loads the select2 property is not applied to my '.date-before-value element. Is there anything I’m missing about loading custom scripts in Omeka?

I moved my initialising code to view/faceted-browse/site/page/facets.phtml and that did the trick. Will I have to copy-paste the code every time I’ll update the plugin?

Yes, it appears that you’ll have to add your custom code every time you update the module.