[ALOY-904] Requesting widgets/requires to receive reference to their parent
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Widgets |
Labels | proxy, require, widgets |
Reporter | Fokke Zandbergen |
Assignee | Tim Poulsen |
Created | 2013-12-18T11:34:35.000+0000 |
Updated | 2014-08-28T21:15:00.000+0000 |
Description
Following the discussion in #ALOY-903 I'd like to request that widgets and required controllers receive their parent element as an argument.
Why I need this... since Alloy 1.3.0
As I've understood from [~tlukasavage] this is similar but not exactly the same as the internally used__parentSymbol
. I think this is in particular true for proxy elements since Alloy 1.3.0. Earlier, these received the __parentSymbol
property and were bound to their parent from within the widget. Since Alloy 1.3.0 however, the binding takes place in the controller that hosts the table and the widget no longer receives the property:
$.__views.is = Alloy.createWidget("nl.fokkezb.infiniteScroll", "widget", {
id: "is"
});
onEnd ? $.__views.is.on("end", onEnd) : __defers["$.__views.is!end!onEnd"] = true;
$.__views.ptr = Alloy.createWidget("nl.fokkezb.pullToRefresh", "widget", {
id: "ptr"
});
onEnd ? $.__views.ptr.on("release", onEnd) : __defers["$.__views.ptr!release!onEnd"] = true;
$.__views.table = Ti.UI.createTableView({
footerView: $.__views.is.getProxyPropertyEx("footerView", {
recurse: true
}),
headerPullView: $.__views.ptr.getProxyPropertyEx("headerPullView", {
recurse: true
}),
headerView: $.__views.ptr.getProxyPropertyEx("headerView", {
recurse: true
}),
id: "table"
});
This is fine and I guess better then before, but I'm sure it's possible to still pass the parent back to the widget?
Attachments
File | Date | Size |
---|---|---|
StarWidget.zip | 2014-03-26T19:31:04.000+0000 | 5800495 |
It would be great if this feature request will be resolved!
Attaching a project the shows how you can access the parent via the $.parent property. Tested with SDK 3.2.2.GA and Alloy 1.3.1. There are some limitations. But perhaps this existing property addresses the requested functionality?
[~skypanther] as your project shows widgets/requires providing 'normal' views still get
__parentSymbol
and can use$.parent
:However, as I explained in the description, widget/requires providing proxy properties do not anymore since 1.3.x. Get the diff?
PR: https://github.com/appcelerator/alloy/pull/370 Functional test Run the sample app included in the PR. In the log output, you should see the message "Widget's parent id is IAmTheParent" and there should be a red label in the window with the text "Created in the widget" which as it suggests, was defined in the code of the widget and added to the parent container using the new reference variable.
Added a failing test to the PR.
PR doesn't address requested functionality and offers no benefit over existing code. PR closed without merging.
A workaround might be to let the widget main view to be empty do that it gets the parent and then manually attach 2nd view of the same widget. Ugly, but might work...