Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Binding multiple values to one label

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Binding multiple values to one label

You want to map two different response parameters to the same label, combine the values and display in the label?

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Binding multiple values to one label

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Binding multiple values to one label

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.

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Binding multiple values to one label

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?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Binding multiple values to one label

Yes, you can. This is the only correct way to get Label value.

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Binding multiple values to one label

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.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Binding multiple values to one label

Save the array into local storage and then iterate over it, setting the label.

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Binding multiple values to one label

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.

Return to “Issues”