Javascript error: cant find variable:(
-
I have a qml file and I am checking for some condition in js file. I imported the js file as Coco in my qml file, and while cheking the condition I gave Coco.function();. an error in the js file "cant find reference variable". The variable is still available in my qml file. I am sure that this is a silly error but am breaking my head off with this. ANy help is appreciated.
-
please post some code
-
JS file
@function val()
{
param_value.text=text_input1.text}
function func() {
if(param_value.text < "70"*1) { param_value.color="red" param_value.font.bold=true dialog.visible=true } else
{
param_value.color="black"
param_value.font.bold=false
dialog.visible=false
}}
@in qml file
//
@
TextEdit {
id: param_value
width: 70
height: 15
text:slider.slidervalue
onTextChanged: Coco.func();font.pixelSize: 12 }@
onClicked: {param_value.text=slider.slidervalue;
Coco.func();
}
error i get is: reference error: cant find variable param_value -
Better than having your id in the javascript, you can pass the id as a parameter
-
sorry dmcr, I did not understand. cud u just quote an example. Thanks
-
i don't know exactly where is your problem since you don't gave the full code with header, etc...
What i was suggesting is just a better manner :
instead of func() {.....
create a function func_(componentId){....
where you can then update values componentId.text = ....