Orbeon JavaScript Embedding: a.querySelector is not a function

Viewed 80

I ma trying to use the orbeon Javascript embedding API, but for some reason I am not able to get it working. I might be missing something. I a, embedding a form into the page and here is a snippet of how i am trying to do it.

ORBEON.fr.API.embedForm(
        'div#orbeon-container',
        '/orbeon',
        'App1',
        'Form1',
        'new'
    );

I am however getting this error Uncaught TypeError: a.querySelector is not a function. I think this could be because of how i am specifying the container, but i am not sure how it should be specified as the documentation on embedding doesn't seem to give an example of this.

2 Answers

The docs you linked state the first parameter is of type HTMLElement (which isn't quite the same as the CSS Selector you might use to address it).

Parameter Optional Type Example Description
container No HTML element DOM element you want the form to be placed in

In other words, instead of

ORBEON.fr.API.embedForm(
    'div#orbeon-container',
    '/orbeon',
    'App1',
    'Form1',
    'new'
);

it should be

let orbeonContainer = document.querySelector('#orbeon-container');

ORBEON.fr.API.embedForm(
    orbeonContainer,
    '/orbeon',
    'App1',
    'Form1',
    'new'
);

The likely issue is that the first parameter must be a DOM element, not a string. Try instead passing the element.

Related