Retrieve setting value from the client side

Plugin Development
  • #1

    Hi, I just written the [nodebb-plugin-katex], and I'd like to change the delimiters inside the formatting.addButtonDipatch function in the client.js script here when the user change the dollarInline setting inside the ACP.

    To do this, I need to get the value of the setting called dollarInline inside this client script. I know that I can retrieve this setting from the server side using:

    meta.settings.get('katex', function (err, options) {
    					console.log(err, options.dollarInline);

    However, I can't figure out how I can get this value from the client side?

  • #3

    Thank you @rbeer, with the help of your examples and th library I implemented it in this commit.

    Here are some elements:

    In the server side I've created a socket with a function to pass the desired config:

    // Create a socket to pass config to the client-side
    PluginSocket.Katex = {};
    PluginSocket.Katex.getConfig = function (socket, callback) {
    var data = {
    dollarInline: _self.config.dollarInline,

    In the client side I retrieve the config from the socket using a jquert deferred.promise:

    // Retrieve config from the plugin socket and then add the composer button
    var Katex = {};
    var deferred = new $.Deferred();
    function callBack(config) {
    Katex.dollarInline = config.dollarInline;
    // do the async call to the socket.
    socket.emit('plugins.Katex.getConfig', callBack);
    // add the usd button to the composer when config caught from socket
  • GNU/Linux

    Always makes me smile when I can help.
    Your plugin also opened nodeBB to a more scientific audience, which I personaly find extra apealing. ­čÖé

Suggested Topics

| | | |