In the alloy structure, I want to dynamically add the view defined in an XML file, but for any other view Not bound on the other.
Container I Index. I'd like to fill in XML:
& lt; Scrollview id = "ScrollBlilan" show paging control = "true" & gt; & Lt; / ScrollableView & gt; The visual template question.xml I want to instcciate every view to go into the scrollable view:
& lt; Alloy & gt; & Lt; Collection creation = "restructuring possible" & gt; & Lt; View ID = "question dialogue" class = "container" & gt; & Lt; Label id = "question text" / & gt; & Lt; Button ID = "button next question" & gt; The question suivante & lt; / Button & gt; & Lt; / View & gt; & Lt; / Alloy & gt; Finally, the controller index.js is a collection example: for (var i = 0; i & lt; questions.length; I ++) {$ .scrollableBilan.add (Alloy.createController ('question', questions.at (i))); } This creates the following message whith crashing my application: 'Unfortunately, your application has stopped'. I already get this error, always trying to add a scene dynamically using Alloy.createController.
The behavior is fine when creating a view with Ti.UI.createView, but I want to use MVC ..
Any help is welcome!
You are passing it to a model object, instead try pass it a JSON object :
for (var i = 0; i & lt; questions.length; i ++) {$ .scrollableBilan.add (Alloy.createController ('question', questions.at ( I) .toJSON ())); } Alternatively you can do this in the XML file and with the datacollection attribute, keep something like this in your index.xml: & lt; Alloys & gt; & Lt; Collection creation = "question" & gt; & Lt; ScrollableView id = "scrollableBilan" showPagingControl = "true" dataCollection = "ReponsePossible" & gt; & Lt; View ID = "question dialogue" class = "container" & gt; & Lt; Label id = "question text" text = "{query}}" & gt; & Lt; Button ID = "button next question" & gt; The question suivante & lt; / Button & gt; & Lt; / View & gt; & Lt; / ScrollableView & gt; & Lt; / Alloy & gt; In your question model the question text field needs to be an attribute.
No comments:
Post a Comment