behavior and appendTo

Discussion and feedback on Construct 2

Post » Tue Dec 20, 2011 8:03 pm

Hi,

I'm looking for a way to append an object to an element (DOM, jQuery etc.) of the index.html, directly with a behavior applied to this object.

I tried with appendChild() and jQuery().appendTo() but it alway returns "Could not convert JavaScript argument arg 0 [nsIDOMDocumentFragment.appendChild]"

Is it possible to manipulate this from a behavior or just not ?
Thankssepteven2011-12-20 20:03:30
Passionate developer

If my work helped you to make your project, please consider making a donation :)
B
44
S
12
G
14
Posts: 631
Reputation: 10,987

Post » Tue Dec 20, 2011 8:31 pm

The Button and Textbox plugins dynamically create HTML form elements and append them to the HTML document, maybe you could have a look at their code.
Scirra Founder
B
387
S
230
G
88
Posts: 24,249
Reputation: 192,450

Post » Tue Dec 20, 2011 10:07 pm

@septeven: something I was doing with the webfont plugin is something like that :
[quote]
var linkTag = "<link rel='stylesheet' type='text/css' href='"+nameOfCSSFile+"' />";
          jQuery('head').append(linkTag);
[/quote]
I suppose you can append to the body via jQuery('body')...
B
33
S
9
G
6
Posts: 708
Reputation: 6,704

Post » Tue Dec 20, 2011 10:12 pm

Thank you @Pode.
As I told to Ashley by PM him, I know how to append in js/jquery (I did it for my ComboBox and Checkbox/Radio plugins) but it doesn't work when I do it directly from a behavior (it works from plugin)...

I'll try to figure out ;)
septeven2011-12-20 22:12:16
Passionate developer

If my work helped you to make your project, please consider making a donation :)
B
44
S
12
G
14
Posts: 631
Reputation: 10,987


Return to Construct 2 General

Who is online

Users browsing this forum: takamoto and 2 guests