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

How to cast a object ? Because of undefined method...

$
0
0

Hi!

This is my problem. I have the index window and the user can click to choose a "symptom". When he clicks, I would like to pass the "symptom object" to the second windows.

1) I created a module which enable to instantiate a object "symptom". 2) in index, I instantiate the "symptom objects" 3) I create the button and the fonction click 3) I use e.souce.mysymptom to know which sympton should be send to the second window. It works 4) In the second window, I receive the parameter but it doesn't know the methode of a object. I suppose I have to cast the object in "symptom" object, isn't it ?

Thank you

index.js

// Create a Button.
var aButton = Ti.UI.createButton({
    symptom : sympt[0]
});
 
// Listen for click events.
aButton.addEventListener('click', function(e) {
    var args = [];
    args.push(e.source.symptom);
    alert(args[0].getTitle().getText()); // it works!
    var sheet = Alloy.createController("sheet", args).getView();
    sheet.open();
});
sheet.js :
var Symptom = require('Symptom');
var symptom = arguments[0] || {}; 
alert(arguments.length); //display 1
alert(symptom.getTitle().getText()); // error, doesn't know getTitle()

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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