Page 1 of 2
Binding multiple values to one label
Posted: Tue Jun 18, 2013 6:29 pm
by Dupdroid
Good day,
I can't get the current value of an element when binding a rest response to it. I would like to append the value to the current value of an element.
e.g.:
function(value, element) {
Code: Select all
var currentValue = element.val();
return currentValue==''?value:currentValue+'.'+value;
}
Regards
Binding multiple values to one label
Posted: Tue Jun 18, 2013 6:55 pm
by maxkatz
You want to map two different response parameters to the same label, combine the values and display in the label?
Binding multiple values to one label
Posted: Tue Jun 18, 2013 7:02 pm
by Dupdroid
Hi Max.
The column that I'm binding to the label is an array. If I add an alert(value); to the javascript it shows all the items in the array one by one. I'd like to append all the array values to the label.
Thanx
Binding multiple values to one label
Posted: Tue Jun 18, 2013 8:18 pm
by Kateryna Grynko
The element is a DOM-element, not a jQuery-object. You would need to place it inside:code $( )/code
The label doesn't have the value inside, so you can't read it using val(). Use function text() instead.
The function should not return anything. That is, you need directly update the label content in the function.
Binding multiple values to one label
Posted: Tue Jun 18, 2013 8:39 pm
by Dupdroid
Not sure I'm following you correctly. Can I use Appery('hiddenLabel').text(); to get the current value?
Or is there a better approach to bind an array column to a hidden label for later use?
Binding multiple values to one label
Posted: Tue Jun 18, 2013 8:47 pm
by Kateryna Grynko
Yes, you can. This is the only correct way to get Label value.
Binding multiple values to one label
Posted: Tue Jun 18, 2013 10:50 pm
by Dupdroid
Still no luck achieving my goal.
When I map an array column to a label I want all the items in the array to be in the label text. (comma separated preferably). This label is hidden and the value will be used later when the user navigates to a different page. I'm only able to map the array items. This causes the label to only hold the first item in the array. How can I map the whole array to the label.
The service response holds multiple clients and each client holds a column with array values. The clients are mapped to a list component. Each list item holds a hidden field where I would like to store the array values.
Hope this makes sense.
Thank you.
Binding multiple values to one label
Posted: Tue Jun 18, 2013 10:51 pm
by maxkatz
Save the array into local storage and then iterate over it, setting the label.
Binding multiple values to one label
Posted: Tue Jun 18, 2013 11:18 pm
by Dupdroid
When I map the array column to a local storage variable the items of the array are set one at a time. I cant's seem to get the whole array to be able to iterate over it as you suggested. I'm doing something wrong obviously.
Binding multiple values to one label
Posted: Tue Jun 18, 2013 11:19 pm
by maxkatz