[ALOY-1738] CLI 8.1.0: crash when to listening backbone.events on required controller in ScrollableView
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-09-14T18:27:05.000+0000 |
Affected Version/s | CLI Release 8.1.0, Alloy 1.15.1 |
Fix Version/s | CLI Release 8.1.1 |
Components | n/a |
Labels | regression |
Reporter | Teun Klijn |
Assignee | Ewan Harris |
Created | 2020-08-28T07:56:26.000+0000 |
Updated | 2021-06-16T14:13:34.000+0000 |
Description
When you add a backbone event listener to a required controller that's nested in a ScrollableView the app will crash. This was working with CLI 8.0.0 and still works correctly with 8.1.0 when the require isn't nested in a ScrollableView.
*To reproduce*
Run the example below with CLI 8.1.0.
+index.js+
function doSomething(e) {
console.log('do something!');
}
$.index.open();
+index.xml+
<Alloy>
<Window class="container">
<ScrollableView>
<Require id="label" src="label" onNotify="doSomething" />
</ScrollableView>
</Window>
</Alloy>
+label.js+
var args = $.args;
function passClick(e) {
$.trigger('notify');
}
+label.xml+
<Alloy>
<Label id="label" onClick="passClick">Hello, World</Label>
</Alloy>
*Expected behavior*
The app will run without crashing and the event is handled correctly.
*Actual behavior*
The app crashes with the following crash message:
"$.__views[\"label\"].on is not a function. (In '$.__views[\"label\"].on('notify', doSomething)', '$.__views[\"label\"].on' is undefined)";
[~teunklijn@telfort.nl] thanks for the comprehensive issue, I'll move this over to the ALOY project
PR: https://github.com/appcelerator/alloy/pull/967 [~teunklijn@telfort.nl], if you wanted to try and patch your CLI locally you can do the following: 1. Open up the appc CLI directory in explorer/finder * Windows: C:\Users\
node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Require.js
3. Apply the changes in the above PRNotes for testing, verify the test case from ALOY-1256 still works, as well as https://github.com/ewanharris/ALOY-1256-test, the test case from this ticket and maybe try the PKO/Community apps as they use the Require tag Edit: Also check out the following widgets test apps [nl.fokkezb.infiniteScroll](https://github.com/Topener/nl.fokkezb.infiniteScroll/tree/test) and [nl.fokkezb.pullToRefresh](https://github.com/Topener/nl.fokkezb.pullToRefresh/tree/test)
Thanks! This does fix my issue.
Verified the fix with 8.1.1-master.8. Closing.