Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a value to a view #3

Closed
NickGulajec opened this issue Apr 18, 2014 · 7 comments
Closed

Passing a value to a view #3

NickGulajec opened this issue Apr 18, 2014 · 7 comments
Labels

Comments

@NickGulajec
Copy link
Collaborator

The parkName label in modal.xml should be based on the row clicked, but I'm having trouble passing that information over.

@kblairwhite
Copy link
Collaborator

I would do the same thing we do just below that for the transect:
example:
var modal = Alloy.createController("modal", {siteID:e.rowData.siteID}).getView();

  • pass the site id, then call the database for your desired information.
    "transects.js" does almost the exact same thing.

@NickGulajec
Copy link
Collaborator Author

I can get the value over to modal.js with:

var args = arguments[0];
function editBtnClick(){alert(args.siteID);}

but is there any way to call args.siteID from modal.xml? I'm just using siteID as example, would probably want to display parkName.

@kblairwhite
Copy link
Collaborator

I don't think so because parkName is only visible in the loop inside the index.js.

This would work in modal.js:

//retrieve siteID
var args = arguments[0];
var siteID = args.siteID;

//Open Database
var db = Ti.Database.open('ltemaDB');

//Query - Retrieve existing sites from database
var row = db.execute('SELECT park_name ' +
'FROM park p, site_survey s ' +
'WHERE p.park_id = s.park_id ' +
'AND s.site_id = ?', siteID);

var parkName = row.fieldByName('park_name');
db.close();

@kblairwhite
Copy link
Collaborator

Or...
The only other thing you could do is pass parkName to the row when it is created in index.js? Don't know whats a better way?

@NickGulajec
Copy link
Collaborator Author

Figured it out.
Instead of creating a label tag in the .xml and trying to assign it a dynamic property,
create the the label in the .js like so:

var args = arguments[0];

var label = Ti.UI.createLabel({ text: args.parkName});

$.modalWin.add(label);

@kblairwhite
Copy link
Collaborator

I know this is closed but, I think I may have misinterpreted the question.
But you can use (in the .js file):
$.ID_of_label.text = "something";

@NickGulajec
Copy link
Collaborator Author

That's perfect, thanks Blair.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants