Back to LanguageTool Homepage - Privacy - Imprint

Customise labels and buttons


(Joshua Flood) #1

I have been following languagetool’s integration guide, adding a spell/grammar check as an additional feature to an existing set of language analysis tools.

The form on my website did not have a name, so I was able to assign it the name ‘checkform’. Unfortunately, including a submit button within the form will break the page format and I do not wish to take advantage of the redirect feature, where a user is directed to the languagetool homepage if there is a problem with the search (though I have included a separate link to the languagetool homepage below the form).

The website I am building relies upon twitter’s Bootstrap v4. All buttons used to analyse text are placed in a separate container below the form. The one which utilises languagetool is defined as follows:

  <div class="col">
    <button id="dashboardLangtoolButton" type="button" class="btn btn-dark btn-lg">Check Spelling & Grammar</button>
  </div>

I have renamed the doit() function defined in the example to executeLangTool(), in order to improve readability within my existing code.

I have also created the following function, to substitute the use of a method/submit button within the form itself:

$(document).ready(function() {
    $('#dashboardLangtoolButton').on('click', function(e) {

        e.preventDefault();

        executeLangTool();

        return false;

    });
});

As previously stated, this button is not contained within the form itself. As it is not of the type ‘input’, I have deemed it unnecessary to include the name tag and, for both of these reasons, I see the following error in the console when I attempt to execute a search:

TypeError: document.checkform._action_checkText is undefined

Is there any simple way that I can alter the tinyMCE scripts in order to provide functionality to the separate button I have created?

Thanks in advance!


(Daniel Naber) #2

_action_checkText is referenced from several places in our code. What happens if you add name="_action_checkText" to your button? You could maybe also add an invisible button with that name, just to avoid the error. Our code simply seems to turn off the button for as long as the check is running.