Problem with lightbox

I've got a problem with my plugin and js.

Without my plugin elgg works fine. But when i activate my plugin, i have the problem that in the river i can't see, who likes my entries. Get an error "Uncaught SyntaxError: Unexpected token" in lightbox.js.php:5 and on click i get the error "Uncaught TypeError: $.colorbox is not a function" in lightbox.cs.php:84

what is the problem? I work with elgg 2.0 and bootstrap. I tried to in start.php to write elgg_load_js('lightbox');
    elgg_load_css('lightbox');

And then in the html.php i included it with the <script..... tag

What could be the problem? What i am doing wrong?

Please help me

  • elgg_load_js() loads the script asynchronously, inline JS is implemented synchronously at runtime before lightbox is loaded.
    Try at least wrapping your JS as an init, system event handler, might help but not bullet proof. In 2.3, lightbox is an AMD module which solves that problem.

  • <script>
    require(['elgg'], function(elgg) {
        elgg.register_hook_handler('init', 'system', function() {
           // put your $.colorbox dependent code here
        });
    });
    </script>
    

    This will probably work in most cases, but might still fail on occasion.

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