Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Generate Collection with a custom tag and the module attribute

$
0
0

ModuleController.js

module.exports.createMyCollection = function() {
  return Alloy.createCollection('my_collection');
};
widget.xml
<Alloy>
  <MyCollection module="ModuleController" id="dataCollection" />
 
  <TableView dataCollection="$.dataCollection">
    <TableViewRow>
      <Label text="Test" />
    </TableViewRow>
  </TableView>
</Alloy>
JS Code after build
var $ = this;
var exports = {};
$.__views.dataCollection = require("ModuleController").createMyCollection({
    args: "arguments",
    instance: "true",
    id: "dataCollection"
});
$.__views.dataCollection && $.addTopLevelView($.__views.dataCollection);
$.__views.__alloyId0 = Ti.UI.createTableView({
    id: "__alloyId0"
});
var __alloyId6 = Widget.Collections["$.dataCollection"] || $.dataCollection;
__alloyId6.on("fetch destroy change add remove reset", __alloyId7);
$.__views.__alloyId0 && $.addTopLevelView($.__views.__alloyId0);
exports.destroy = function() {
    __alloyId6.off("fetch destroy change add remove reset", __alloyId7);
};
_.extend($, $.__views);
_.extend($, exports);
Error [ERROR] : TiApplication: (main) [1496709,1496709] Sending event: exception on thread: main msg:java.lang.ClassCastException: java.util.HashMap cannot be cast to org.appcelerator.titanium.proxy.TiViewProxy; Titanium 3.5.1,2015/03/05 10:08,96875c9

If I understand this correct, this mean that the collection is no UI element. Can i tell the Titanium Studio that my custum tag generates a collection and no UI Element?

The JS Code after build should be

var $ = this;
var exports = {};
$.dataCollection = require("ModuleController").createMyCollection({
    args: "arguments",
    instance: "true",
    id: "dataCollection"
});
$.dataCollection && $.addTopLevelView($.dataCollection);
$.__views.__alloyId0 = Ti.UI.createTableView({
    id: "__alloyId0"
});
var __alloyId6 = Widget.Collections["$.dataCollection"] || $.dataCollection;
__alloyId6.on("fetch destroy change add remove reset", __alloyId7);
$.__views.__alloyId0 && $.addTopLevelView($.__views.__alloyId0);
exports.destroy = function() {
    __alloyId6.off("fetch destroy change add remove reset", __alloyId7);
};
_.extend($, $.__views);
_.extend($, exports);
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>