Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Bind model to view, from controller?

$
0
0

Coming from asp.net mvc, im having some issues understanding this MVC.

Consider the code in this example: https://github.com/prakash-anubavam/alloypreloadedsqlitedb/tree/master/app

I do understand that one way to bind a model to a view, is for example, using tables like this:

<TableView id="table" dataCollection="fighters" onClick="showId" dataTransform="transformData">
Which (correct me if im wrong) will use my fighters singleton instance data, and my fighters.js as the model. Which will then be used in the view row.js and access its data like '{name}'.

Now theres one view, details.xml, with these two:

<Label id="name" text="{name}"/>
<Label id="nickname" text="{nickname}"/>
How does the view know, which model (and which instance!) will it get the name and nickname properties from? In .net you would declare the model in the view file (if strong typed) and just send a model instance from the controller to the view, but in this code i see no where in the controller something that binds the model to the view, neither in the view.

I do see how in the index.js controller, it calls the details controller sending the model variable, but i dont understand how does that variable get binded to the view.

Would it be right to do something in the controller like: $model = some model or $.details.model = some model or $.model = some model ? I cant find anything like this in the docs.

Can i do in the view instead of "{name}", something like "{myModel.Name}" ?


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>