Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello guys,
I have a problem with getting the value of the textarea of my extension. I am trying with jquery but it doesn't work:
console.log($(props.items.appearance.items.myButton).val());
Appreciate any help.
Thanks,
Todor
Ok I don't really know why but the layout property is not assigned to the $scope, but rather to the $scope.$parent property .
If you replace your controller with the the following code you'll see an object containing properties like "layout", "component", "backendApi" etc. in the console:
controller: ['$scope', function ($scope) {
var myExtScope = $scope.$parent;
console.log(myExtScope);
}]
The path to your property-value will then be: myExtScope.layout.props.buttonName
(because you set the "ref" property inside the property.js myButton variable to "props.buttonName")
I think there's something wrong though because Qlik documentation states:
"Add console.log('layout', $scope.layout); into your controller to help you find all the properties."
which is (surprisingly) wrong.
Mathias
Hello Todor,
the "$(...)" is usually expecting an jQuery selector like:
$('#myButton') --> returns the html element with the id "myButton" (e.g. <button id="myButton">Button-Text</button> or <div id="myButton"></div>).
What you probably want is just: console.log(props.items.appearance.items.myButton)
If you want to look inside the properties-structure you can also just do a: console.log(props)
For a better understanding check out the section about custom properties in the Qlik Sense documentation (Adding custom properties ‒ Qlik Sense)
Mathias
My example might be a bit misleading.. because I want to get the value of my textbox/textarea.
This text ("dasdasd") i want.
P.S.: I have searched the help but couldn't find a solution ..
Did you try my suggestions?
If you post your stripped down extension code I'm probably able to help you better.
Yes, this is an example of my extension with your solution.
P.S.: I dont want to get the default value but the value from the user input
Ok I don't really know why but the layout property is not assigned to the $scope, but rather to the $scope.$parent property .
If you replace your controller with the the following code you'll see an object containing properties like "layout", "component", "backendApi" etc. in the console:
controller: ['$scope', function ($scope) {
var myExtScope = $scope.$parent;
console.log(myExtScope);
}]
The path to your property-value will then be: myExtScope.layout.props.buttonName
(because you set the "ref" property inside the property.js myButton variable to "props.buttonName")
I think there's something wrong though because Qlik documentation states:
"Add console.log('layout', $scope.layout); into your controller to help you find all the properties."
which is (surprisingly) wrong.
Mathias
It works perfectly. Thanks Mathias!
Hello again Mathias!
Do you know how to catch the event when something is entered in the specific textbox? For example, I want to enter the name of the displayed button in this textbox.
Regards,
Todor
Hello,
I don't know how to subscribe to the change event of a specific property (other than finding the textbox via a jQuery selector) but you can use the Validated Event for your extension:
Occurs if the data has been recalculated and new valid data is available.
myExtScope.component.model.Validated.bind( function () {
console.info('new value', $scope.$parent.layout.props.buttonName);
} );
More on events can be found in the documentation: AngularJS and events ‒ Qlik Sense
Mathias