Binding more objects in JavaScript


#1

Hi all, I want to bind two string var in order to get data from two textfields on the view (XML) to the model (JS), and an Image in order to set the image object on the view (XML) from the model (JS)… How can I do?

this is part of my JS file

var postDetails = new Observable ({

  description: "",

  price: "",

  rating:0,

  location:

    {

        lat:0,

        lng:0

      },

  data: 

      {

        year:0,

        day:0,

        month:0

      }

});

exports.loaded=function(args)

{ 

  page=args.object;

  viewModel=new Observable({

    myImage:page.navigationContext.pic,

    price: postDetails.price,

    description:postDetails.descriptio

  });

  page.bindingContext=viewModel;

This is part of my XML

<TextView id="Description" text="{{ description }}" class="TextField" style="height:150;" hint="What did you eat?" />

         </StackLayout>

    </StackLayout>

    

    <StackLayout class="stackLayoutFood" style=" margin-top:5px; margin-bottom:5px; margin-right:10px;" orientation="horizontal">

      <Label class="Label" text="Price:" style="margin-top: 12px;" />

      <TextField id="Price"  text="{{ price }}" class="TextField" hint="Insert here..." /> 

#2

nobody can help me ?


#3

what have you tried in the xml to bind? Couple of ways to do this.


#4

I have tried to create a view through a var and just to bind from the method of the page but nothing works…


#5

Can you provide a code sample please?


#6

It’s on top in the main message


#7

I guess I’m having trouble visualizing what you want to do, but maybe the info on this thread might help with concatenation: Autocomplete in Android or an Autocomplete plugin


#8

I have resolved the issue, into the xml I had put “value:{{ price }}” instead of “text: {{ price }}”