Problem with elgg_require_js

I am having problems with elgg_require_js API. Though the js files are loaded, its not getting executed.

Here is my scenario

  • Elgg 3.3.4
  • All plugins disabled, except a custom plugin called "test" which is very simple and contains only
    • start.php
    • manifest.xml
    • views/default/js/test.js
  • In test/start.php I have the following code.
<?php
 
function test_init() {
elgg_require_js('js/test');
}
 
return function() {
elgg_register_event_handler('init', 'system', 'test_init');
};
  • In views/default/js/test.js I have

define(function(require) {
    var elgg = require("elgg");
    var $ = require("jquery");

    $('body').append(elgg.echo('hello_world'));
});

In the network tab of my browser, I can see the js file got loaded, but nothing is getting appended to the body.

Any thoughts?

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking