ACP: JavaScript

Plugin Development

Suggested Topics


  • 0 Votes
    2 Posts
    285 Views

    @v_risalab i figured it out. The acp code uses browserify and the widget code uses webpack!

  • 0 Votes
    1 Posts
    165 Views

    Hi,

    How to require local utilities in my acpScript properly? I want to separate functions in my acpScript of my plugin into several JS files. My acpScipt is located at path public/lib/admin/index.js with codes:

    'use strict'; /* globals socket, define, require */ define( 'admin/plugins/myPlugin', [ 'myAdminUtilities' ], function (util) { const Admin = {}; Admin.init = function () { socket.emit( 'plugins.myPlugin.getData', myAdminUtilities.handleResponse, ); }; return Admin; } );

    Then, file myAdminUtilities is located at path public/lib/admin/utils.js with codes:

    define('admin/plugins/myAdminUtilities', function () { const adminUtils = {}; adminUtils.handleResponse = function (error, data) { // process data ... }; return adminUtils; });

    Also, I have modified my plugin.json with following:

    { ... "modules": { "myAdminUtilities": "public/lib/admin/utils.js" }, ... }

    But, I get get admin/plugins/myAdminUtilities (404 Not found) every time I enter my plugin ACP page. What's the proper way to reach my goal?

  • 0 Votes
    2 Posts
    2k Views

    in the client, those values are stored in ajaxify.data

    For your jQuery, you don't append a closing tag, it does that automatically. When you want to insert the element into the div, you need to use appendTo(). Also, unless your label has additional data, I recommend using html() instead of text().

    Here's a fiddle. I also added an ID to the new label so it isn't added more than once.
    https://jsfiddle.net/bdLgsj7p/

  • 1 Votes
    3 Posts
    2k Views
    templates.render ('tpl/name', {}, function() { // templates.cache['tpl/name'] });

    I think so anyways, I'm writing this from my phone

  • 0 Votes
    6 Posts
    3k Views

    i removed pidfile and it started normally