Titanium Community Questions & Answer Archive

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

How to reload window?

Hi, I have a window and would like to create a button. This button is to reload the current window once it is clicked. May I know how can I reload the content of current window?

Ti 1.6.1, Android 2.2

— asked April 2nd 2011 by David Lee
  • reload
  • window
4 Comments
  • does your window contain views? then you could rather refresh their content, text, images etc. maybe a piece of code would make it easier to guess…

    — commented April 2nd 2011 by u no
  • It is a tableview, with the data from

    var loader = Titanium.Network.createHTTPClient();

    I would like to refresh the table view by recalling the data with

    loader.open() and loader.onload()

    — commented April 2nd 2011 by David Lee
  • Upon clicking of the button do you resend the request? I would resend the request then put code for populating the tableview in the onload method.

    — commented April 2nd 2011 by Matthew Fong
  • Yes, I would want to resend the request after clicking the button, and then change and update the tableview.

    — commented April 3rd 2011 by David Lee

1 Answer

  • I haven't worked a whole lot with HTTPClient, but from what I've read you should just be able to call the loader.send() method in your button's 'click' event listener. Whenever you receive the information you've requested the loader.onload() method will be called, so make sure to define it before you send the request.

    In the loader.onload() method you can use the tableView.updateRow method or tableView.insertRowAfter and table.remove to update your table. There is also a tableView.setData method.

    The docs for tableView and HTTPclient:
    http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.TableView-object.html
    http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Network.HTTPClient-object.html

    — answered April 3rd 2011 by Matthew Fong
    permalink
    0 Comments
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.