Help using Jquery

For developers using the Construct 2 Javascript SDK

Post » Wed Jun 12, 2013 2:52 am

@Ashley
I`m making behavior. I need to apply css class to behavior instance. How i can do that? i`m trying use jQuery(this.inst).addClass('my_class'); on text object or button, but without success. Even if i use (for debug) jQuery(this.inst).hide(); this function not working. Can you help me?SirG2013-06-12 02:53:53
ImageImage
B
78
S
25
G
7
Posts: 190
Reputation: 10,256

Post » Wed Jun 12, 2013 12:59 pm

this.inst refers to the javascript object representing an object in the Construct 2 engine. It doesn't make any sense at all to pass it to jQuery. You probably meant to pass something else.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,464

Post » Wed Jun 12, 2013 10:32 pm

@Ashley
can you advice me? i have add standart button plugin and text object on layout, then apply my behavior. in behavior i have made action HideObject, which makes jQuery(this.inst).hide();, but it doesn`t work. I have made action ApplyClass, which apply jQuery(this.inst).addClass('my_class'); and it is not working too. what i`m doing wrong?SirG2013-06-12 22:32:45
ImageImage
B
78
S
25
G
7
Posts: 190
Reputation: 10,256

Post » Thu Jun 13, 2013 2:26 pm

The statement jQuery(this.inst) makes no sense at all. Look up the jQuery documentation. You need to pass it a selector string or DOM object. Instead you're passing something completely unrelated (a javascript object for a Construct 2 instance). I don't know what you're trying to do, but you definitely shouldn't be using this.inst there.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,464

Post » Thu Jun 13, 2013 9:13 pm

B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

Post » Sun Jun 16, 2013 1:42 pm

@Joannesalfa @Ashley
this can help when using standart plugins like button. it has ID propery. But what if i want (for example) 10 buttons with same style? i need 10 different ID, and for each one writing css properties...it will be more easier if C2 developers implement css files support and Css Class property for objects. Are you agree with me?
ImageImage
B
78
S
25
G
7
Posts: 190
Reputation: 10,256


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests