Plugin Initialization Sample Code Question

I’m looking at the sample plugin code for the initialize() function in the Bubble manual…

function( instance, context )
{
    var div;

    div = window.u.div( 'div', instance.canvas, 'click here' );

    div.css( 'width', '100%' );
    div.css( 'height', '100%' );
    
    div.click( function( a ) {
        return instance.triggerEvent('appointment_clicked', function(){
            return console.log( 'done' );
        });
    });
}

Where does window.u come from? Is it part of a JS framework or something? Is it something with which a plugin developer should be familiar?

I have this same question - why has no one responded to this obvious question that I’m sure other newcomers might be wondering about? window.u is still in the docs, and there is no code completion for it. It’s also not clear in the docs the best why to actually generate an element for the plugins. I think this most obvious subject should be included in the docs. I’m guessing since there isn’t anything specific on the subject the course is to simply create an element in any way and attach it as a child to the instance.canvas element.

1 Like

uhm… I think u is just a variable the documentation writer created and appended to the window object.

You can read more here:
https://www.w3schools.com/jsref/obj_window.asp

https://www.w3schools.com/js/js_window.asp

2 Likes

I know it was added. The question was really if that is a convention to be followed or not (like Bubble UI builder code or something). How is any newcomer supposed to know the difference? That example should be replaced.

3 Likes