Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6010517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:07:39+00:00 2026-05-23T02:07:39+00:00

I am trying to pass a simple string to an event listener in order

  • 0

I am trying to pass a simple string to an event listener in order to identify an appropriate array object to modify. I understand by looking at the log (shown in comments) that what I am passing is an object and it can’t be compared directly to another object’s property.

Should I pass an object that has the string as a property (like the array object does), or is there a more appropriate way to reference the object as a string or call its name somehow (like the log does in the first comment)?

// I just want to pass a string as an argument. Here is a static example.
var timestampID = '1307740835264';
Ti.App.fireEvent('confirmation',timestampID);

Notice how the first log output interprets the argument as a string, but the if comparison recognizes it as an object.

Ti.App.addEventListener('confirmation',function(timestampID) { // produces "[DEBUG] fire app event: confirmation with 1307740835264"
    Ti.API.info(timestampID); // produces "[INFO] { type = confirmation; }"
    for (i=0;i<myArray.length;i++) {
        Ti.API.info(myArray[i].timestampID + ' | ' + timestampID); // produces "[INFO] 1307740835264 | [object Object]"
        if (myArray[i].timestampID == timestampID) { // will produce false
            // will never happen
        }
    }
});

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:07:40+00:00Added an answer on May 23, 2026 at 2:07 am

    So to me it looks like the timestampID being passed in to the handler is an object, however from the second statement (and accompanying [INFO] comment), I have absolutely no idea what properties it has. Let’s assume that it has a property called timestamp. Then your if statement should be

    if (myArray[i].timestampID === timestampID.timestamp) 
    

    But that’s about all I can glean from this code snippet I’m afraid.

    UPDATE: OK, I see how you’re triggering the event. The Titanium API is bafflingly obtuse on this point (it looks like the help for fireEvent is wrong: two parameters called “name”?). There are no examples that I can see. However it does say that what you pass in as the data is (must be?) serialized as JSON.

    Now that I know that, looking at the second statement’s [INFO] line it makes more sense. It’s a string that has the JSON data. Your data is missing since it was a string value. Try this to fire:

    Ti.App.fireEvent('confirmation', { timestampID: '1307740835264' } );
    

    and this in the event handler:

    Ti.App.addEventListener('confirmation', function (data) {
      for (i=0;i<myArray.length;i++) {
        if (myArray[i].timestampID === data.timestampID) { 
            ...code...
        }
    }
    

    });

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass an array of a simple object to a web
I'm trying to pass an array to my template with a simple tag. I
I'm trying to make simple script using jquery $post function to pass data to
I'm trying to build a simple GAE application that would read a textbox, pass
Trying to pass in a user supplied string which has a path to the
Trying to pass a string argument to a function, which will then be used
I am trying to use string.format on a url to pass several values into
Ok so I am trying to pass some string variables from a classic ASP
I'm trying to make a simple String to SHA1 converter in Java and this
I'm trying to pass variables to a simple PHP script and have it redirect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.