lawls
lawls

Reputation: 1508

KineticJS - Pass DOM element to constructor

According to the documentation of Kineticjs the container of the stage can be either a string with an elment's id, or a DOM element. So I wonder why this doesn't work:

stage = new Kinetic.Stage({
    container: $(".my-element"),
    width: 200,
    height: 200
});

I have verified that .my-element exists and all. I get the following error:

Uncaught TypeError: Object [object Object] has no method 'appendChild'

Upvotes: 0

Views: 179

Answers (1)

markE
markE

Reputation: 105035

You are passing a jQuery object instead of an html element.

So do this instead which gets the actual html element:

container: $(".my-element")[0],

Upvotes: 1

Related Questions