Reference Guide
Reference Guides / JavaScript API / Events / RegisterOnSearchInvoked
In This Topic
    In This Topic

    This function allows you to trigger a function of your own when the text search feature has been invoked (this event is triggered when the search process is done).

    DocuVieware™ default behavior displays an information message with a localized "no result found" notice, this message isn't displayed when this callback is defined to let you override this default behavior with your own.
    RegisterOnSearchInvoked: function (docuViewareID, callback)


    The identifier for the DocuVieware™ instance.
    The function you want to execute on event.
    The callback provides an argument having a prototype { occurrences }.
    - occurrences is an integer value representing how many results have been found.

    Return Value

    1 if error.

    Example of usage

    This JavaScript makes sure the DocuVieware control is properly loaded and initialized and then subscribes to the event on search invoked. If there's no result, it displays an alert box with "no result found" message.

    function RegisterOnSearchInvokedOnDocuViewareAPIReady() {
        if (typeof DocuViewareAPI !== "undefined" && DocuViewareAPI.IsInitialized("DocuVieware1")) {
            DocuViewareAPI.RegisterOnSearchInvoked("DocuVieware1", function (result) {
                if (result.occurrences == 0) {
                    alert("no result found");
        else {
            setTimeout(function () { RegisterOnSearchInvokedOnDocuViewareAPIReady() }, 10);
    document.addEventListener("DOMContentLoaded", function () {
    }, false);