-
Notifications
You must be signed in to change notification settings - Fork 69
Callback Functions
There are two callback functions that can be utilized for customizing your use of bibtex_js.
The bibtex_display
callback function is called once bibtex_js is done processing all the entries and displaying them. The example below shows how to use it:
<div id="bibtex_display" callback="function(bibtex_display)"></div>
or
<div class="bibtex_display" callback="function(bibtex_display)"></div>
<div class="bibtex_display" callback="function2(bibtex_display)"></div> <!-- Can be a different function -->
In the above example, we have a hypothetical function that takes in the value bibtex_display
. This value provides the function, or any function provided direct access to the HTML element, in our case a div
element. It can be considered the this
for accessing the HTML DOM element. The value of the callback
attribute is interpreted as a new JavaScript function. See example code below (note that using class rather than id works similar except that each instance of bibtex_display
is processed and a callback is called for each one):
var bibtex_display = $("#bibtex_display");
if (bibtex_display.attr("callback")) {
var callback = new Function('bibtex_display', bibtex_display.attr("callback"));
callback(bibtex_display[0]);
}
The bibtex_template
callback function is called each time a bibtex entry is added to the webpage. The example below shows how to use it:
<div class="bibtex_template" callback="function(bibtexentry)"></div>
In our example above, we have a hypothetical function that takes in the value bibtexentry
. The value provides the function with access to the specific bibtex entry that is being added to the webpage (not the general template). This provides the function with direct DOM access to the HTML element, in our case a div element. The value of the callback attribute is interpreted as a javascript function, the same as shown previously.