Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Remove a view from a different js file

In my app.js I created a window that has a separate js file (news.js).

In my news.js I have a tableview. How can I remove that tableview within my app.js?

Thanks!

— asked August 18th 2010 by Chris Schultz
  • android
  • remove
  • view
0 Comments

1 Answer

  • Accepted Answer

    Work with Titanium.App.fireEvent and Titanium.App.addEventListener: in the API docs.

    In app.js do this:

    Titanium.App.fireEvent('remove_tableview');
    

    .. to call the function from news.js:

    Titanium.App.addEventListener('remove_tableview', function(data) {
        win.remove(my_tableview);
    });
    

    Note that the data object is a optional parameter (check the docs for more info).

    — answered August 18th 2010 by Richard Venneman
    permalink
    2 Comments
    • This is the correct answer, but I'll let the poster ratify that ;).

      — commented August 18th 2010 by Kevin Whinnery
    • Perfect. Thanks!

      — commented August 19th 2010 by Chris Schultz
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.