Usage in JavaScript

Content Browser can be called at will anywhere from your JavaScript code.


Before you can use the Content Browser, you need to include its assets in your page head:

<meta name="ngcb-base-path" content="{{ path('ngcb_root') }}">
<link rel="stylesheet" href="{{ asset('netgen-content-browser.css', 'ngcb_css') }}">
<script src="{{ asset('netgen-content-browser.js', 'ngcb_js') }}"></script>

or just include the provided Twig template:

{% include '@NetgenContentBrowser/page_head.html.twig' %}

All HTML code blocks which have js-input-browse or js-multiple-browse CSS class will be automatically initialized on document ready with jQuery and the plugin which are included in netgen-content-browser.js.

If you use another CSS class, or if you add content browser HTML code via AJAX to your page, you will need to manually initialize the plugin on those elements:

// ngc_jquery variable holds jQuery included with Netgen Content Browser
ngc_jquery('.js-input-browse').input_browse(); // for single item select
ngc_jquery('.js-multiple-browse').multiple_browse(); // for multiple item select

Calling the Content Browser from your JavaScript