PDA

View Full Version : how to create static variable in java script



hema
4th August 2011, 12:10
hi,

my app some balloons with a text inside.

i have to arrange them alphabetically.

to do, i have to create a static array such that when ever a balloon is clicked,a signal from qml to .js deletes first element of array

is it correct procedure?

error: signal deletes the element but for every click new array is generating

is there any other procedure to do?

its urgent. any one please answer

regards,
hema

SixDegrees
4th August 2011, 12:32
If it's that urgent, you should consider posting on a JavaScript forum. Qt has nothing to do with JavaScript.

For what it's worth, it sounds like you need a global variable, not a static one. But I loathe JavaScript, so I could be wrong.

hema
4th August 2011, 12:38
hi,

i gave a global variable in .js
but, separate variable is getting created for every component. i need only one for whole app.

SixDegrees
4th August 2011, 12:46
Like I said: go find a JavaScript forum. Your question has nothing to do with Qt.

wysota
4th August 2011, 12:47
but, separate variable is getting created for every component.
So by definition the variable is not global. There are no static variables in javascript. Make the variable a property of the global object and it will be global.