Multiple widgets

There are certain occasions where you may wish to use multiple widgets on a single page. For us to do this succesfully we require you to initialise the widgets and send us the required information. The easiest way for you to do this is to send us the ISBN or DOI that each cite button should use to receive it’s information.

To initialise them separately, please follow the instructions found on this page.

Initialise multiple widget’s at once

It may be easier to initialise all widgets in just one script include, to do so you will need to store some information on the div element that we can retrieve in JavaScript. If we just send just the DOI or ISBN information for each widget, we would need to insert the div’s like the following:

<!-- Replace XYZ with the identifier (ISBN or DOI) -->
<div id="cite-XYZ" data-id="XYZ" class="js__refme-cite">

Be sure to output the ISBN or DOI where XYZ is in the above snippet. Then we need to insert the JavaScript just above the closing body tag of the webpage.

<script async src="http://widget.refme.com/scripts/refme-cite.js"></script>
<script> 
    document.onload = function () { 
        var elements = document.querySelectorAll('.js__refme-cite');

        [].forEach.call(elements, function (el) {
            var isbn = el.getAttribute('data-id');
            RefME.createButton({ 
                element: '#cite-' + isbn, 
                data: {lookup: isbn} 
            }); 
        }); 
    }; 
</script>