Topener / nl.fokkezb.pullToRefresh

Widget to implement a table pull-to-refresh header in Titanium Alloy
184 stars 60 forks source link

Create this widget programatically #59

Closed annamf closed 8 years ago

annamf commented 8 years ago

I have to create the widget programatically but I can't add the table view like a child of the widget because it isn't a view. Is this possible?

My code is:

    var ptr = Alloy.createWidget("nl.fokkezb.pullToRefresh", {
        onRelease: myRefresher()
    });

    var table = Ti.UI.createTableView({
      id: ('table' + i),
      data: tableData,
      separatorStyle: OS_ANDROID ? Ti.UI.TABLE_VIEW_SEPARATOR_STYLE_NONE : Ti.UI.iPhone.TableViewSeparatorStyle.NONE,
      headerView: header.getView()
    });
    ptr.add(table); // This crashes
FokkeZB commented 8 years ago

Hi @annamf,

It's not officially supported, but as Alloy will pass children views as $.args.children and the widget expects this argument you could try:

var ptr = Alloy.createWidget('nl.fokkezb.pullToRefresh', {
  children: [table]
});

ptr.on('release', myRefresher);